How to plot step functions in Matlab
Ältere Kommentare anzeigen
I have a function involving
y=o for x<o;
y=exp(-x)*cos(x) for 0<x<2pi();
y=2*exp(-x)*cos(x) for x>2pi();
please help me to plot such a type of function in xy space
Akzeptierte Antwort
Weitere Antworten (1)
Vladimir Sovkov
am 31 Okt. 2020
Bearbeitet: Vladimir Sovkov
am 31 Okt. 2020
syms x;
y=piecewise(x<0,0, 0<=x<2*pi,exp(-x).*cos(x), x>=2*pi,2*exp(-x).*cos(x));
t=linspace(-pi,4*pi,1000);
plot(t,subs(y,x,t));
2 Kommentare
Sangani Prithvi
am 31 Okt. 2020
Vladimir Sovkov
am 31 Okt. 2020
Welcome.
By the way, in the question, you did not specify what the function is equal to at the boundary points x=0 and x=2*pi; in the code I implied the right limit but you can easily alter this convention.
Kategorien
Mehr zu Annotations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!