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