I need help graphing a function.

The code creates a graph but I'm pretty sure it's wrong because It's supposed to look closer to a cos(x) graph
t=linspace(0,100,101);
y=(3.*((2.71828).^(-t./2))).*(cos(4.*pi.*t));
plot(t,y);
grid

 採用された回答

Star Strider
Star Strider 2023 年 9 月 27 日

0 投票

It probably should be a decaying sinusoid.
The problem is that it decays too fast. Decreasing the magnitude of ‘t’ helps to visualise it correctly. (I suspect the problem is the ‘exp(-t./2)’ term. The constant should be smaller than 0.5 to get the result you lilely want with the original ‘t’.)
t=linspace(0,100,101)/10;
y = 3.*exp(-t./2).*cos(4.*pi.*t);
plot(t,y);
grid
.

2 件のコメント

Brendan
Brendan 2023 年 9 月 27 日
Thank you. That is exactly what i was looking for.
Star Strider
Star Strider 2023 年 9 月 27 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeNetworks についてさらに検索

タグ

質問済み:

2023 年 9 月 27 日

コメント済み:

2023 年 9 月 27 日

Community Treasure Hunt

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

Start Hunting!

Translated by