frequency analysis with a Waterfall
36 views (last 30 days)
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);
[p,f,t] = pspectrum(TreBu_output.Window,general.sampl_frequency_in_Hz,'spectrogram');
title(['Frequency waterfall ', Name]);
wtf = gca;
wtf.XDir = 'reverse';
Arthi Sathyamurthi on 20 Jul 2021
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