필터 지우기
필터 지우기

Creating a cosine oscillation ( cos(2 * pi * f * k * T) )

조회 수: 30 (최근 30일)
Ahmad
Ahmad 2023년 4월 10일
편집: Image Analyst 2023년 4월 10일
Hello,
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

채택된 답변

Askic V
Askic V 2023년 4월 10일
Hi Ahmad,
you can can think of k*T as a time vector, one example is:
k = 1:2000; T = 1/Fs;
tf = k*T;
y = A*cos(2*pi*f*k*T);
plot(tf,y)

추가 답변 (1개)

Image Analyst
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);
grid on;
xlabel('T');
ylabel('y');
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?

카테고리

Help CenterFile Exchange에서 Signal Attributes and Indexing에 대해 자세히 알아보기

제품


릴리스

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by