What I want is quite simple, or so I thought. I have many spectograms to compute and display which is time consuming to compute, so I want to save them in variables to display them without redoing the computation. The problem is that I can't find a way to plot them like they appear if I directly use the function spectogram().
Example :
sampling_rate = 100;
spectrogram(data,100,20,[],sampling_rate,'yaxis');
caxis([-20 60])
This displays a spectogram exactly as I want it :
I read the doc and I understand that I can save the results by doing something like this :
[S,F,T] = spectrogram(data,100,20,[],sampling_rate);
Also, I know that the function spectogram internally calls surf().
I found this post that seems to give a solution to my problem by doing this :
[S,F,T] = spectrogram(data,100,20,[],sampling_rate);
surf(T,F,abs(S),'EdgeColor','none');
axis tight; view(0,90);
But I get this plot, which is far from what I expected:
The axis labels and colorbar are gone, and the colors are completely not scaled. If I do this manually by adding colorbar; caxis([-20 60]);
as previously, I get this thing:
Isn't there a simple solution to save a spectogram and display it on command ?
Like S = spectogram(...)
then plot(S)
?