Main Content

叠加阶梯图和线图

此示例演示如何在阶梯图上叠加线图。

定义要绘图的数据。

alpha = 0.01;
beta = 0.5;
t = 0:10;
f = exp(-alpha*t).*sin(beta*t);

f 显示为阶梯图。使用 hold 函数保留阶梯图。使用带有星形标记的虚线添加 f 线图。

stairs(t,f)
hold on 
plot(t,f,'--*')
hold off

Figure contains an axes object. The axes object contains 2 objects of type stair, line.

使用 axis 函数设置坐标轴范围。标记 x 轴并向图形添加一个标题。

axis([0,10,-1.2,1.2])
xlabel('t = 0:10')
title('Stairstep plot of e^{-(\alpha*t)} sin\beta*t')

Figure contains an axes object. The axes object with title Stairstep plot of e toThePowerOf -( alpha *t) baseline blank sin beta *t, xlabel t = 0:10 contains 2 objects of type stair, line.

另请参阅

| |