Creating a cosine oscillation ( cos(2 * pi * f * k * T) )
조회 수: 20 (최근 30일)
I need help wiht producing a cosine oscillation with sampling frequency = 10KHz and a signal length = 2000 samples. The frequency(f) is equal to 100 Hz and the amplitude is equal to 50. I can't figure out what k exactly is.
Can anyone please help me
Thank you in advance
추가 답변 (1개)
Image Analyst 2023년 4월 10일
편집: Image Analyst 님. 2023년 4월 10일
A cosine wave is of the form
y = Amplitude * cos(2 * pi * omega * time)
So for your formula
Amplitude = 50;
and I beleve T is your time vector.
omega is the frequency which is f*k for you. I believe f is the lowest frequency, and it's equal to 100, and is what you'll get when k = 1. If you increase k you get harmonics of f so you'll get waveforms at twice the frequency, 3 times the frequency, 4 times the frequency, etc.
If the sampling frequency is 100000 hz, the delta between time samples is 1/10000. So after 2000 samples your time value would be 2000/10000 = 0.2 seconds. So you can construct T, your time vector, using linspace like this:
T = linspace(0, 0.2, 2000);
So in all you get
f = 100;
k = 1;
y = Amplitude * cos(2 * pi * f * k * T);
% Now plot it.
plot(T, y, 'b-', 'LineWidth', 2);
Note you get 20 oscillations (periods) in 0.2 seconds, so you'd get 100 of them in 1 second, as you should with k=1 and f=100. If you increase k you get more oscillations in the same time interval.
I hope this helps explain it better. If it does, could you Accept the answer and/or click the "Vote" icon?