Asked by Lorenzo Castellari
on 3 Jun 2012

I am new to Matlab and signal processing, I am a mechanical engennering grad school student and I have to analyze the vibration of a fixed beam hit with an instrumented hammer. The input signal is the impulse force of the hammer, ffted, [23203x1] array, the output signal comes from an accelerometer and it's also a ffted [23203x1] array. I want to measure the coherence between input and output with mscohere but I am not sure about the parameters that I have to set up in the function, the only thing I'm sure about is my sampling frequency fs which is 2048. Idon'tknow which values to put in for window, noverlap and nfft. The result I wish to obtain is coherence for the first 4 natural frequencies of the fixed beam, which are(in my output ffted array) at 11 70 196 384 Hz. I hope I explained the problem well, I'm sorry but I'm missing a whole background on signal processing so I find it hard even to explain what I'm doing because I'm not sur of anything. Many thanks to whoever tries to help me out Lorenzo

Answer by Wayne King
on 3 Jun 2012

Accepted answer

The key thing for you is to choose a window length that allows you to ensure that your frequencies of interest fall directly on DFT bins. You have long time series, which is fortunate. By picking the segment (window) length equal to the sampling frequency, you have a spacing in the Fourier domain of 1 Hz. At the same time, you are able to get enough overlapped segments at that length to produce a good coherence estimate.

I've used an overlap of 2000 samples, but that can be played with a bit. Here is an example using your general problem where I simulate two signals, x and y.

winlen = 2048; dt = 1/2048; t = 0:dt:(23203*dt)-dt; x = cos(2*pi*11*t)+sin(2*pi*70*t)+cos(2*pi*196*(t-pi/4))+sin(2*pi*384*(t-pi/8))+randn(size(t)); y = 0.5*cos(2*pi*11*(t-pi/3))+2*sin(2*pi*70*t)+cos(2*pi*196*(t-3*pi/4))+sin(2*pi*384*(t-pi/4))+randn(size(t)); [Cxy,F] = mscohere(x,y,hamming(winlen),2000,winlen,2048); plot(F,Cxy); xlabel('Hz'); ylabel('Magnitude-squared Coherence'); axis tight;

Lorenzo Castellari
on 3 Jun 2012

Thanks for the answer Wayne.

As far as I understood the window length affects which frequency is well evaluated with the coherence function, the best value for my case is the sampling frequency 2048.

I still don't get a lot of things, for example how the overlapping samples affect the results, why I have to use an hamming windowing 2048 long.

But most of all I get a plot which has tons of pikes very sharp and close to each other and none of them corresponds to the frequencies I mentioned.

Thanks for the reply, sorry for my total ignorance on this topic.

Lorenzo

Alan Armstrong
on 5 Jul 2013

Hi Lorenzo,

I'm attempting more of less the same thing and I have similar questions to you regarding the hamming window and window size etc. Did you manage to get any more clarity on this issue for your code?

thanks,

Alan

Related Content

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn moreOpportunities for recent engineering grads.

Apply Today
## 0 Comments