From e3f83c1c91a1de19c586cb32ed99e011a002f2c7 Mon Sep 17 00:00:00 2001 From: ZaellixA <axilleaz@protonmail.com> Date: Tue, 16 Jul 2024 12:32:32 +0100 Subject: [PATCH] Add an additional parameter to mulCoh.m to also get the multiple coherence --- .../Generic/MATLAB/Functions/mulCoh.m | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Virtual Sensing/Generic/MATLAB/Functions/mulCoh.m b/Virtual Sensing/Generic/MATLAB/Functions/mulCoh.m index 758eef5..c7b1498 100644 --- a/Virtual Sensing/Generic/MATLAB/Functions/mulCoh.m +++ b/Virtual Sensing/Generic/MATLAB/Functions/mulCoh.m @@ -3,7 +3,7 @@ % Author: Achilles Kappis % e-mail: axilleaz@protonmail.com % -% Date: 12/07/2024 (DD/MM/YYYY) +% Date: 16/07/2024 (DD/MM/YYYY) % % Copyright: MIT % -------------------------------------------------- @@ -27,6 +27,8 @@ % -------------------------------------------------- % Output % +% cohSq [numeric]: The multiple coherence squared. +% % coh [numeric]: The multiple coherence. % % -------------------------------------------------- @@ -36,12 +38,12 @@ % virtual signal and physical signals in remote acoustic sensing" by % P. Zhang, S. Wang, H. Duan, J. Tao, H. Zou and X. Qiu. % -------------------------------------------------- -function coh = mulCoh(Px, Py, Sqq, xRegFac) +function [cohSq, coh] = mulCoh(Px, Py, Sqq, xRegFac) % ==================================================== % Check for number of arguments % ==================================================== narginchk(2, 4); - nargoutchk(0, 1); + nargoutchk(0, 2); % ==================================================== % Validate input arguments @@ -78,7 +80,11 @@ function coh = mulCoh(Px, Py, Sqq, xRegFac) Syy = Py * Sqq * Py'; Sxy = Px * Sqq * Py'; - % Calculate multiple coherence - coh = diag((Sxy'/(Sxx + xRegFac * eye(size(Sxx, 1))) * Sxy)./Syy); - coh = real(coh); % Make sure to get rid of residual imaginary parts + % Calculate multiple coherence squared + cohSq = diag((Sxy'/(Sxx + xRegFac * eye(size(Sxx, 1))) * Sxy)./Syy); + cohSq = real(cohSq); % Make sure to get rid of residual imaginary parts + + if nargout > 1 + coh = sqrt(cohSq); + end end \ No newline at end of file -- GitLab