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!