필터 지우기
필터 지우기

How would I plot a sin wave.

조회 수: 4 (최근 30일)
Nicholas Deosaran
Nicholas Deosaran 2020년 9월 17일
답변: Sai Sri Pathuri 2020년 9월 22일
Hey all how would this be coded?
For a period of 10 seconds and an amplitude of 1 meter, develop a variable that consists of a sine wave of 2 periods where data are determined every tenth of a second.
i have an idea like this
t = [0:1/10:10];
y = 2*sin(t);
plot (t,a)
But I dont know if that is corrent
  댓글 수: 2
Vinicius Pereira Mateus Borges
Vinicius Pereira Mateus Borges 2020년 9월 17일
Hello, the full sine wave function is
sinW = a * sin(2*pi*f*t + theta)
% a is amplitude
% f is frequency
% t is time
% theta is the angle offset
Your answer is mainly correct, but it is missing the 2*pi. You should also probably increase your sampling rate to 1:1/1000:10 to get a better resolution in your plot.
Asad (Mehrzad) Khoddam
Asad (Mehrzad) Khoddam 2020년 9월 17일
For period of 10 seconds, f =1/10 or f=0.1 in the above equation.

댓글을 달려면 로그인하십시오.

채택된 답변

Sai Sri Pathuri
Sai Sri Pathuri 2020년 9월 22일
Since you want to plot a sine wave of 2 periods in a time of 10 seconds, the time period of sine wave must be 5.
freq = 1/5;
sineWave = sin(2*pi*freq*t);
As amplitude required is 1, you need not multiply the sine wave with any coefficient. Hence, sineWave variable defined above is suffice. You can plot it as
plot(t,sineWave)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by