trying to plot a more complicated step function
Afficher commentaires plus anciens
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.
Réponses (1)
Azzi Abdelmalek
le 23 Avr 2016
Modifié(e) : Azzi Abdelmalek
le 23 Avr 2016
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)
Catégories
En savoir plus sur Animation dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!