Trying to plot the multiplication of triangular and unit step signal.
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Tasin Nusrat
am 14 Sep. 2022
Beantwortet: Walter Roberson
am 14 Sep. 2022
I am trying to plot a signal x(t) where
x(t)=0 for t<0
x(t)=0 for t>=1
x(t)=-t+1 for 0≤t≤1
I write the code as follows:
t=-5:5
x(t)= 0*(t<0)+(-t+1).*((0<=t)&&(t<=1))+0*(t>=1);
but its not showing the correct plot. I think the problem is with writing x(t)=-t+1 for 0≤t≤1 condition. I am expecting the plot to be like

0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 14 Sep. 2022
t = -5:.01:5
x = (1-t) .* (0<=t & t<=1);
stairs(t, x)
axis equal
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Sources finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!