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?
0 个评论
回答(2 个)
Sulaymon Eshkabilov
2021-5-22
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
2021-5-23
编辑: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.
Sulaymon Eshkabilov
2021-5-25
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')
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Multirate Signal Processing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!