I need help graphing a function.

1 vue (au cours des 30 derniers jours)
Brendan
Brendan le 27 Sep 2023
Commenté : Star Strider le 27 Sep 2023
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

Réponse acceptée

Star Strider
Star Strider le 27 Sep 2023
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 commentaires
Brendan
Brendan le 27 Sep 2023
Thank you. That is exactly what i was looking for.
Star Strider
Star Strider le 27 Sep 2023
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by