two coherent and two correlated signals in Matlab

조회 수: 4 (최근 30일)
Sadiq Akbar
Sadiq Akbar 2021년 5월 22일
답변: Sulaymon Eshkabilov 2021년 5월 25일
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
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
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.
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
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')

카테고리

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