How to plot step functions in Matlab
Mostrar comentarios más antiguos
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
Respuesta aceptada
Más respuestas (1)
Vladimir Sovkov
el 31 de Oct. de 2020
Editada: Vladimir Sovkov
el 31 de Oct. de 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 comentarios
Sangani Prithvi
el 31 de Oct. de 2020
Vladimir Sovkov
el 31 de Oct. de 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.
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!