Plotting Cos complete stupidity
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Massimo Zanetti
2016-9-28
编辑:Massimo Zanetti
2016-9-28
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!