how to validate mscohere?

6 次查看(过去 30 天)
I would like to validate the use of mscohere for impact test data, using an instrumented hammer that measures force and an accelerometer to measure response. I ran some artificial cases - see attached pdf. Single input, single output. I tried to force mscohere to use only 3 windows of data, one for each impact test. The first half of results are for sinusoidal input and output, and the second half are for a simulated impact input. There are 2 time domain plots in there. The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically. Sample rate is 1000 Hz, with a 4 second window and 0.25 Hz resolution. I am using a rectangular window:
[coherence, frequencies2] = mscohere(coherenceInput, coherenceOutput, rectwin(windowLength), 0, windowLength, sampleRateHz);
The results look about right to me, but I would like to validate it against some known or anlytical results. Are there any suitable examples available?
Also, how do I check that it is getting the absolute basics right - for example, is it using the 3 windows of data that I want it to use?

采纳的回答

William Rose
William Rose 2025-5-16
You say there are two time domain plots, but I see three. Each of the three time domain plots shows an input and an output. I You say "The inputs are the 3 input vectors stacked vertically, and the 3 output vectors stacked vertically." I would not do this, since it creates a signal which may have discontinuities at the boundaries, and those discontinuities in the output would probably look different if the entire concantenated input signal had been run thorugh the system.
To get a coherence estimate with small error bars, I recommend using 8 or more segments, not three. I say that because coherence is estImated from ratios of cross-power and auto-power spectrum estImates. The power spectrum esitmates have variances on the order of (signal power)/sqrt(number of segments). With three segments, the power spectrum estimate variance is on the order of (signal power)/1.73, which can lead to large error bars on the coherence, when using real data.
I am attaching some files of simulated data I made for coherence testing years ago. Each file has two columns: x (input) and y (output). Fs=1000 Hz; number of samples = 1024. The input (x) is the same in all the files. The input is band-limited white noise (30 to 300 Hz). The output equals the input plus uniform noise. The noise is uniform on [-a.+a]. The noise amplitude a is different in ther different files, and the actual random values of the added noise are different. The noise amplituides and files are:
File a=noise half-amplitude
coh1_01xy.txt 0.1
coh1_03xy.txt 0.3
coh1_10xy.txt 1.0
coh1_20xy.txt 2.0
We expect the coherence to be lower when there is more noise on the output, and we exect large error bars on coherence estimates at frequencies where there is little power in the input - because when there is little or no power in the input.
I reocmmend using a Hamming window with half-overlapped segments.
data=load('coh1_10xy.txt'); % produces an error when I run it in Matlab Answers window
% but it works when I run it on my computer
x=data(:,1); y=data(:,2); % x=input, y=output
N=length(data); % total nmber of samples
Fs=1000; % sampling rate (Hz)
Nd=8; % number of disjoint segments
nseg=round(N/Nd); % samples per segment
[cxy,f]=mscohere(x,y,hamming(nseg),round(nseg/2),nseg,Fs);
plot(f,cxy,'-b.');
grid on; xlabel('Frequency (Hz)')
title('Coherence'); ylabel('\gamma^2')
Code above produces plot below:
If we plot the coherences for all 4 files, we get
Note that when the noise amplitude (a) is larger, the estimated coherence is lower, as expected. The estimated coherence is low and variable at the frequencies where there is little input power (0 to 30 Hz and >=300 Hz), as expected.
  8 个评论
CM
CM 2025-5-18
编辑:CM 2025-5-18
Also, I was able to reproduce the coherence predicted by your equation if, for the incoherent part of the signal, I used 3 sin waves, each offset by 120 degrees. I also tried with random noise, but the results were all over the place, both positive and negative errors of up to 0.7 for the coherence.
I also validated mscohere against the result obtained the 'long' way from cpsd and pwelch, which was the same. I don't think I'll bother looking for the lower lever calculation.
William Rose
William Rose 2025-5-18
@CM, good job on calculating the (estimated) coherence spectrum with cpsd and pwelch!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Spectral Estimation 的更多信息

标签

产品


版本

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by