trying to plot a more complicated step function

I need an equation for a function y(t) where; y(t) = 0 from 0 < t < 1.25; y(t) = -0.18 from 1.25 < t < 2.5; y(t) = 0 from 2.5 < t < 7.5;
It's not necessarily a matlab question but I can't figure out how to plot this step function in matlab. One equation would be helpful as opposed to a piecewise function.

回答 (1 件)

Azzi Abdelmalek
Azzi Abdelmalek 2016 年 4 月 23 日
編集済み: Azzi Abdelmalek 2016 年 4 月 23 日

0 投票

ts=0.01
t1=0:ts:1.25-ts
t2=1.25:ts:2.5-ts
t3=2.5:ts:7.5
t=[t1 t2 t3]
y=[t1*0 -0.18*ones(size(t2)) 0*t3]
plot(t,y)
or
t=0:ts:7.5
y=-0.18*(heaviside(t-2.5)-heaviside(t-1.5))
plot(t,y)

カテゴリ

ヘルプ センター および File ExchangeAnimation についてさらに検索

タグ

質問済み:

2016 年 4 月 23 日

編集済み:

2016 年 4 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by