Plotting Cos complete stupidity
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have been plotting trig functions like this for years in matlab with zero problem Now all of a sudden it no longer works.
x = [0:.1:20]
y = .5*cos(2*pi*60.*x)
plot(x,y)
Now today all i get is a constant value. What is going on here
Doing the following makes no difference
x = [0:.1:20]
plot(x,.5*cos(2*pi*60.*x))
Someone please tell me why in the holy land of matlab multiplying the vector X by a constant of 2*pi*60 completely ruins the plot and turns it into a constant. It makes zero sense!
but yet somehow this works
plot(x,cos(x))
All I'm doing is multiplying the foreign X by a constant of 2*pi*60 This is ridiculous
Also just to add the following works
y = cos(2*x) y = cos(2*pi*x)
But for some insane reason the plot goes nuts when you plot
y = cos(2*pi*60*x) and says the plot is a constant .5
Also just to add to the infuriation of this if you plot
plot(x,.5*cos(120*pi*x)) %you get a constant of .5
plot(x,.5*cos(119*pi*x)) %you get a proper oscillating cos
0 commentaires
Réponse acceptée
Massimo Zanetti
le 28 Sep 2016
Modifié(e) : Massimo Zanetti
le 28 Sep 2016
This is not ridiculous, this is math.
Try refine the step of x:
x = 0:.01:20;
y = .5*cos(2*pi*60*x);
plot(x,y)
Your "weird" phenomenon is due to the fact that all cosine crests fall into the discretized interval you choose, which is too coarse to make you see them.
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Graphics Objects 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!