frequency analysis with a Waterfall

70 次查看(过去 30 天)
Hey community
I would like to compare different datasets by a time-frequency based analysis method. I have in mind a waterfall diagram. Is it possible to get from this diagram specific values like maximum magnitude and the corresponding frequency, or the average excited frequency (similar to the spectral centroid in an FFT)? Here is the code I am using and an image of the waterfall.
Best regards and thank you in advance
Abb_2 = figure(2);
set(gcf,'position',[20,20,1200,600]);
[p,f,t] = pspectrum(TreBu_output.Window,general.sampl_frequency_in_Hz,'spectrogram');
waterfall(f,t,p');
xlabel('Frequency (Hz)')
ylabel('Time (seconds)')
zlabel('Magnitude (V^2)')
title(['Frequency waterfall ', Name]);
xlim([0 2e5])
colorbar
wtf = gca;
wtf.XDir = 'reverse';
view([30 45])

回答(1 个)

Arthi Sathyamurthi
Arthi Sathyamurthi 2021-7-20
Hello Fabian,
To get diagram specific values like maximum magnitude with their corresponding frequency and time, from just visualization you can use a datatip in the figure window by just clicking on the maximum point or you can use the datatip function in MATLAB if you know the positions already.
In case you don’t know the maximum value and wish to calculate it, you can use the max function. Copy the following code to your program to calculate it.
[maxValuesofSpectrum, indexMaxValuesofSpectrum] = max(p,[],'linear'); % Maximum magnitudes for each individual time value of the spectrogram
[maxValue, indexMaxValue] = max(maxValuesofSpectrum); % Maximum magnitude among all the time values of spectrogram
[rowIndexofMaxValue, columnIndexofMaxValue] = ind2sub(size(p),indexMaxValuesofSpectrum(indexMaxValue));
f(rowIndexofMaxValue); % Spectrum frequency corresponding to the maximum magnitude
t(columnIndexofMaxValue); % Time value corresponding to the maximum magnitude
You can comment out the 2nd and 5th line if you want to find the maximum magnitude for each individual time

类别

Help CenterFile Exchange 中查找有关 Multirate Signal Processing 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by