i am not getting correct output for this plot

t=0:0.01:1; a=cos(2*pi*100*t); plot(a);

2 件のコメント

madhan ravi
madhan ravi 2018 年 8 月 16 日
I think you want to do fft analysis?
chetan meti
chetan meti 2018 年 8 月 16 日
no.i want to plot cosine wave with frequency of 100 hz.i am a beginner

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

 採用された回答

Stephan
Stephan 2018 年 8 月 16 日
編集済み: Stephan 2018 年 8 月 16 日

0 投票

Hi,
the reason for this behavior is that your sampling rate (t) is 100 Hz. The steps of t = 0.01 and the integer multiples of 100 result in the calculation of a, being always an integer multiple of 2 * Pi. This always results in 1. If you want to calculate for 100 or Integer multiple from 100, you should change the sampling rate. Maybe a prime number which is not in your range to calculate is a good choice.
So it can be said, that the plot is correct, but it is not doing what you expected for the reason mentioned above.
EDIT:
In addtion, you should have a look what happens, if you do 50 or 25 - this will not be a cosine wave but a Kind of sawtooth, which is also a result of the sampling rate t=0.01 you have choosen. By choosing 50 you get an a which is always -1 1 -1 1 -1 1...
It gets even worse if you use 33 or 34 - try that. Then suddenly it looks as if you are dealing with superimposed oscilations, although this is definitely not true, because if you scan with t = 0.001, you recognize the correct behavior.
So you should think about the range of your values and then choose a sampling rate which is giving you the expected results.
Best regards
Stephan

1 件のコメント

chetan meti
chetan meti 2018 年 8 月 16 日
thank you so much sir,your answer is very useful

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

その他の回答 (0 件)

質問済み:

2018 年 8 月 16 日

コメント済み:

2018 年 8 月 16 日

Community Treasure Hunt

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

Start Hunting!

Translated by