How to plot step functions in Matlab
Mostra commenti meno recenti
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
Risposta accettata
Più risposte (1)
Vladimir Sovkov
il 31 Ott 2020
Modificato: Vladimir Sovkov
il 31 Ott 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 Commenti
Sangani Prithvi
il 31 Ott 2020
Vladimir Sovkov
il 31 Ott 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.
Categorie
Scopri di più su Annotations in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!