coherence plot and correlation plot,time domain to frequency domain

Asked by Sana Ejaz

Sana Ejaz (view profile)

on 1 Jul 2019
Latest activity Answered by Navya Seelam

Navya Seelam (view profile)

on 17 Jul 2019
Accepted Answer by Navya Seelam

Navya Seelam (view profile)

Hi ,
I have attached a sample data.I want to create a correlation as well as coherence plot for the attached time series data.
In order to understand the difference between time and frequency domain of time series I need to plot both correlation and coherence of same time series so that I can spot and understand the difference.Since I am new to the frequency domain concept I don't know how to measure coherence and how to make coherence plot.My understanding is that in order to measure coherence I would need to convert the time series that is in time domain to frequency domain.But I dont know how to do that.
Would highly appreciate if someone can help.

Answer by Navya Seelam

Navya Seelam (view profile)

on 17 Jul 2019

Hi,
If you have the Signal Processing Toolbox, use the function "mscohere" to plot coherence.
n = 0:599;
x = cos(pi/4*n)+randn(size(n));
y = 1/2*sin(pi/4*n)+randn(size(n));
[Cxy,W] = mscohere(x,y);
Plot(W,Cxy)
You can obtain the correlation using the function "xcorr"
C=xcorr(x,y);
For more details check the MATLAB documentation of the above functions