two coherent and two correlated signals in Matlab

24 vues (au cours des 30 derniers jours)
Sadiq Akbar
Sadiq Akbar le 22 Mai 2021
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?

Réponses (2)

Sulaymon Eshkabilov
Sulaymon Eshkabilov le 22 Mai 2021
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 commentaires
Sulaymon Eshkabilov
Sulaymon Eshkabilov le 23 Mai 2021
Modifié(e) : Sulaymon Eshkabilov le 23 Mai 2021
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 le 23 Mai 2021
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?

Connectez-vous pour commenter.


Sulaymon Eshkabilov
Sulaymon Eshkabilov le 25 Mai 2021
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')

Community Treasure Hunt

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

Start Hunting!

Translated by