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
Dyuman Joshi 2023-9-30
An error occurs in this line -
ylim(-6:6);
This is not how ylim works.
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
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')

类别

Help CenterFile Exchange 中查找有关 Time Series 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by