Plotting a time series e^(-at) cos((bt) u_s (t)) for two cases, first for a=3 and b=50, then for a=-3 and b=50.
2 ビュー (過去 30 日間)
古いコメントを表示
I have been trying to plot the time series (e^(-at)*cos(bt)*u_s(t))) for two cases, first for a=3 and b=50, then for a=-3 and b=50 . Plot both cases on the same plot. Let the vertical axis span from -6 to 6 and the horizontal axis from 0 to 1 seconds.
Please help me rewrite this code:
a1=3;
b1=50;
a2 = -3;
b2= 50;
f1 = exp^(-a1*t)*cos(b1*t)*u(t);
f2 = exp^(-a2*t)*cos(b2*t)*u(t);
ts1 = timeseries (f1,0:1);
ts2 = timeseries(f2,0:1);
ts1.Name = 'time series';
ylim(-6:6);
plot(ts1);
hold on
plot(ts2);
2 件のコメント
Dyuman Joshi
2023 年 9 月 30 日
An error occurs in this line -
ylim(-6:6);
From the documentation - "Specify limits as a two-element vector of the form [ymin ymax], where ymax is greater than ymin."
And you don't need to define the variables as timeseries object. Plot directly, as has been show below.
You can also use fplot
回答 (1 件)
KSSV
2023 年 9 月 30 日
clc; clear ;
a1=3;
b1=50;
a2 = -3;
b2= 50;
t = linspace(0,1) ;
f1 = exp(-a1*t).*cos(b1*t) ;
f2 = exp(-a2*t).*cos(b2*t);
plot(t,f1,'r');
hold on
plot(t,f2,'b');
ylim([-6 6])
legend('f1','f2')
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Time Series についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!