MATLAB: Need help with 3D-plot

3d plotsfft

Hi there,
I would like to ask how exactly can I plot 3D plot such as this
from my 2D plot, which represents X-Y axes.
I´m using this code
load m2.txt;
i=m2(:,2);
ia=i*1000;
fs=50000;
T=1/fs;
L=length(ia);
t=(0:L-1)*T;
nfft=2^nextpow2(L);
w=hann(L);
io=ia.*w;
I=fft(io,nfft)/L;
Ia=abs(I);
f=fs/2*linspace(0,1,nfft/2+1);
%Normal.
Iref=max(Ia);
Inorm=20*log10(Ia/Iref);
figure;
plot(f,(Inorm(1:nfft/2+1)));
set(gca, 'YLim',[-130,0]);
set(gca, 'XLim',[0,500]);
xlabel('f (Hz)','FontSize',9);
ylabel('Magnituda (dB)','FontSize',9);
hold on;
So I obviously need to add the Z-axis, which represents length of the signal (time). I need to find out for how long ceratin frequencies were present during the measurement.
Tried to use "surf" and "plot3" commands, but all my attempts failed, so I would be really, really thankful for any insight.
Regards,
Patrik

Best Answer

The image in your Question is a Signal Processing Toolbox spectrogram (link) plot, although with a different view. The spectrogram function produces a surf plot with a default view(0,90) so you are looking down at it as a 2D plot rather than viewing it as a 3D plot. You can use the GUI to rotate it, or simply experiment with different arguments to the view function after you plot it. The documentation for the spectrogram function describes how to do all of this, so I will not discuss it in detail here.