Need help with 3D-plot
显示 更早的评论
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
2 个评论
Ameer Hamza
2018-4-26
"but all my attempts failed"
What have you tried so far? What errors did you get?
Patrik Soukup
2018-4-26
编辑:Patrik Soukup
2018-4-26
采纳的回答
更多回答(1 个)
Ameer Hamza
2018-4-26
The figure you posted can be made using plot3. Try Running this script. You will get the idea how to use plot3 to draw such graphs.
f = figure;
t = 0:0.01:10;
plot3(0, 0, 0);
ax = gca;
delete(ax.Children);
hold on;
for i=1:5
plot3(ax, t, 2*i*ones(size(t)), sin(i*t)+rand(size(t)));
end
4 个评论
Patrik Soukup
2018-4-26
Ameer Hamza
2018-4-27
Are you using a version of MATLAB earlier than 2014b?
try replacing
delete(ax.Children);
with
delete(get(ax, 'Children'));
Patrik Soukup
2018-4-27
Thsnisorn Auk
2023-5-28
I really have same problem. Could you help me to plot it but in my case i was to plot x= frequency, y =time, z = amplitude .
Thank you.
Regards.
Sorn
类别
在 帮助中心 和 File Exchange 中查找有关 Spectral Measurements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!