How to plot step functions in Matlab
古いコメントを表示
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
採用された回答
その他の回答 (1 件)
Vladimir Sovkov
2020 年 10 月 31 日
編集済み: Vladimir Sovkov
2020 年 10 月 31 日
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 件のコメント
Sangani Prithvi
2020 年 10 月 31 日
Vladimir Sovkov
2020 年 10 月 31 日
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.
カテゴリ
ヘルプ センター および File Exchange で Annotations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!