two coherent and two correlated signals in Matlab

4 次查看(过去 30 天)
How can we generate two coherent signlas in Matlab? Likewise how can we generate two correlated signlas in Matlab. Furhter how will we differentiate that these two signals are coherent and these two are correlated? I have a piece of code but don't understand that these are coherent or correlated?
close all;
clc;
clear all;
w = [pi/4 pi/4 pi/2]';%Frequency
P = length(w); %The number of signal
M=5; %Number of array elements
sig=2*exp(j*(w*[1:M])); % two coherent signlas
So the questions are why are these coherent signlas? And if these are coherent, then how will we generate correlated signlas? Further how will we find covariance matrices of coherent signals and correlated signlas?

回答(2 个)

Sulaymon Eshkabilov
Hi Sadiq,
Here is a short script that demonstrates and shows if there is a coherence and correlation between the two generated signals.
close all; clc; clearvars;
w = [pi/4 pi/4 pi/2]'; % Frequency
P = length(w); % Number of signals
N=10; % Number of data points in the generated signals
S=2*exp(1j*(w*(1:N))); % Three signals generated
x=S(1,:);
y=S(2,:);
[Cxy,F] = mscohere(x,y) % Coherence between x and y signals computed
figure('name', 'Coherence')
plot(F,Cxy)
title('Magnitude-Squared Coherence')
xlabel('Frequency (Hz)')
grid
figure('name', 'X-correlation')
crosscorr(x, y) % Cross-correlation between x and y
Good luck.
  3 个评论
Sulaymon Eshkabilov
编辑:Sulaymon Eshkabilov 2021-5-23
If you don't have these toolboxes, then the above written code of mine can't be used in your matlab package.
Then you'd need to compute the coherence and x-correlations using the equations given here:
https://en.wikipedia.org/wiki/Coherence_(signal_processing)
Good luck.
Sadiq Akbar
Sadiq Akbar 2021-5-23
Thank you very much dear Sulaymon for your 2nd response. That seems too technical for me. Can you do some changes in the above so that it can be run my system?

请先登录,再进行评论。


Sulaymon Eshkabilov
close all; clc; clearvars;
w = [pi/4 pi/4 pi/2]'; % Frequency
P = length(w); % Number of signals
N=10; % Number of data points in the generated signals
S=2*exp(1j*(w*(1:N))); % Three signals generated
x=S(1,:);
y=S(2,:);
%% Calcs without MATLAB toolboxes
X_fft = fft(x, N);
Y_fft = fft(y, N);
H = Y_fft./X_fft;
Gxx = abs(X_fft).^2;
Gyy = (abs(H).^2).*Gxx;
CH_xy = (abs(H.*Gxx).^2)./(Gxx.*Gyy);
figure
plot(CH_xy), title('Coherence')
CC =x.*y;
figure
stem(1:N, CC), title('Cross-correlation of x and y signals')

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by