How do I plot 5e^(0.5t)sin(2*pi*t)

9 ビュー (過去 30 日間)
Monqiue Parrish
Monqiue Parrish 2023 年 2 月 24 日
コメント済み: Les Beckham 2023 年 2 月 24 日
% I have tried to plot 5e^(0.5t)sin(2pi*t) but my graph just show a negative exponential
% But when I compared to demos it's completely wrong
t1 = 0:10;
e = exp((0.5)*t1);
num6 = (5).*e.*sin((2)*pi*t1);
plot(t1, num6, 'c')

採用された回答

Les Beckham
Les Beckham 2023 年 2 月 24 日
編集済み: Les Beckham 2023 年 2 月 24 日
t1 = 0:10;
e = exp((0.5)*t1);
num6 = (5).*e.*sin((2)*pi*t1);
plot(t1, num6, 'c')
grid on
You are plotting your exponential term multiplied by the sine of integer multiples of 2*pi which should be zero. Due to floating point precision issues, it is instead very close to zero and increasing in a negative direction. This causes your plot to look the way it does.
t1 = 0:10;
plot(t1, sin(2*pi*t1), '.')
grid on
If you add points that aren't integer multiples of 2*pi you will see the real behavior of your equation.
t1 = 0:0.01:10;
e = exp(0.5 * t1);
num6 = 5 * e .* sin(2*pi*t1);
plot(t1, num6, 'c')
grid on
  2 件のコメント
Monqiue Parrish
Monqiue Parrish 2023 年 2 月 24 日
Thank you that makes more sense now.
Les Beckham
Les Beckham 2023 年 2 月 24 日
You are quite welcome.

サインインしてコメントする。

その他の回答 (2 件)

Torsten
Torsten 2023 年 2 月 24 日
移動済み: Torsten 2023 年 2 月 24 日
Note that sin(2*pi*t) = 0 for t = 0,1,2,3,...,10.
And these are the only points for t you specified.
  1 件のコメント
Steven Lord
Steven Lord 2023 年 2 月 24 日
You can see this even better if you use sinpi instead of sin.
format longg
t = (0:10).';
y1 = sin(2*pi*t)
y1 = 11×1
1.0e+00 * 0 -2.44929359829471e-16 -4.89858719658941e-16 -7.34788079488412e-16 -9.79717439317883e-16 -1.22464679914735e-15 -1.46957615897682e-15 -1.71450551880629e-15 -1.95943487863577e-15 -2.20436423846524e-15
y2 = sinpi(2*t)
y2 = 11×1
0 0 0 0 0 0 0 0 0 0

サインインしてコメントする。


Image Analyst
Image Analyst 2023 年 2 月 24 日
You had so few points that you were subsampling the shape away and couldn't see the oscillations. Use more data points. by using linspace. Try it this way:
t1 = linspace(0, 10, 1000);
e = exp(0.5 * t1);
num6 = 5 .* e .* sin(2 * pi * t1);
plot(t1, num6, 'c-', 'LineWidth', 2);
grid on
xlabel('t1')
ylabel('num6')
title('num6 = 5 .* e .* sin(2 * pi * t1)')

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by