I am trying to make a cos function at 19.8kHz, but the function produced by cos does not look like one, why is that?
1 view (last 30 days)
Show older comments
%% Time specifications:
Fs = 80000; % samples per second
dt = 1/Fs; % seconds per sample
StopTime = 0.25; % seconds
t = (0:dt:StopTime-dt)'; % seconds
%%Sine wave:
Fc = 19800; % hertz
x = cos(2*pi*Fc*t);

This is what I did, and what I got from the plot command. What is the correct way to get a cos graph?
1 Comment
Stephen23
on 16 Nov 2017
"What is the correct way to get a cos graph?"
By generating enough samples. Your sample rate is way too low.
Answers (1)
David Goodmanson
on 16 Nov 2017
Hi Justin,
right now you are seriously undersampled on the cosine wave. You have 80000/19800 = 4.04 samples per cycle, so you catch very few points on the wave. If you raise your sampling frequency by a factor of 5 or 10 you will see much better results.
0 Comments
See Also
Categories
Find more on Graph and Network Algorithms in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!