Generating Step Function In MATLAB.

Hi, Can anyone help me in generating a step function which increases by an increment of 1 unit and then remain constant for 1 unit and then again increases by 1 unit,remain constant for 1 unit and so on (upto a certain height,say 5 unit) and then again decreasing by the same amount, remaining constant for the same amount as while increasing, in MATLAB? Thanking You!

 采纳的回答

k.v.swamy
k.v.swamy 2012-1-5

2 个投票

try this code N=21; x=0:N-1; y=5*ones(1,N) stem(x,y)

更多回答(1 个)

Titus Edelhofer
Titus Edelhofer 2012-1-5

0 个投票

Hi Pranjal,
take a look at the function stairs that makes this task rather simple ...
Titus

类别

在 帮助中心 和 File Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by