MATLAB: Hi everybody, I have a question about coherence and mscohere function

MATLABsignal processing

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, [23203×1] array, the output signal comes from an accelerometer and it's also a ffted [23203×1] 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

Best 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;