我正在尝试在Matlab中将几个波形绘制到相同的图中;这是全新的。我尝试使用plot()将它们全部绘制在一起,但它不能适当地缩放它们。我该如何扩展它们呢?我在网上读到了一些使用hold on的东西,但我相信我也遇到了同样的问题。这里的简单解决方案是什么?
t1 = 0:0.1:1000;
y1 = t1.^5-5*t1.^3+4*t1;
plot(t1, y1)
hold on
t2 = 0:0.0001:0.01;
y2 = -8*exp(-1000*t2) + 3;
plot(t2, y2)
hold on
t3 = 0:0.0001:0.6;
y3 = exp(-10*t3).*cos(100*t3);
plot(t3, y3)
hold on
%plot(t1, y1, t2, y2, t3, y3)发布于 2019-12-03 18:59:33
Matlab正在做您要求它做的事情:将所有内容绘制到同一个轴系统(顺便说一句,您只需要使用hold on一次,在您更改轴或命令Matlab之前,它是活动的)。您有三种选择
xlim([xmin xmax])和ylim([ymin ymax]),也可以联合使用axis([xmin xmax ymin ymax]) (在您的情况下,例如axis([0 0.6 0 3.3])yyaxis left / yyaxis right以激活轴。请注意,这只提供了两个不同的轴比例就是这样
% 1st subplot
t1 = 0:0.1:1000;
y1 = t1.^5-5*t1.^3+4*t1;
ax(1) = subplot(3,1,1);
plot(t1, y1)
% 2nd subplot
t2 = 0:0.0001:0.01;
y2 = -8*exp(-1000*t2) + 3;
ax(2) = subplot(3,1,2);
plot(t2, y2)
% 3rd subplot
t3 = 0:0.0001:0.6;
y3 = exp(-10*t3).*cos(100*t3);
ax(3) = subplot(3,1,3);
plot(t3, y3)
% link all axes (but only x direction)
linkaxes(ax,'x')
% your axes limits are so large that you probably don't want to link themhttps://stackoverflow.com/questions/59145267
复制相似问题