Don't get what is happening in matlab sin() function. need to know difference between sin(2*50*pi*t) and sin(2*1*pi*t)

조회 수: 2(최근 30일)
AK Nahin 2022년 9월 9일
답변: William Rose 2022년 9월 9일
Hi,
I am using Matlab to plot the sin graph. But when I put sin(2*50*pi*t) it shows something else than the sinusoidal curve. Can you please help me to find out why it is happening? Thanks in advance.
Code:
t = 0:0.1:20;
x = sin(2*50*pi*t);
y = sin(2*1*pi*t);
subplot(2,1,1)
plot(t,x)
subplot(2,1,2)
plot(t,y)
댓글 수: 1표시숨기기 없음
Steven Lord 2022년 9월 9일
It wouldn't help in this case but if you're computing the sine of pi times some angle, consider using the sinpi function instead of explicitly computing pi times the angle and calling sin.

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

채택된 답변

Torsten 2022년 9월 9일
t1 = 0:0.001:1;
x = sin(2*50*pi*t1);
t2 = 0:0.1:1;
y = sin(2*1*pi*t2);
subplot(2,1,1)
plot(t1,x)
subplot(2,1,2)
plot(t2,y)
댓글 수: 3표시숨기기 이전 댓글 수: 2
William Rose 2022년 9월 9일
OK will do.

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

추가 답변(1개)

William Rose 2022년 9월 9일
In your original code, you were evaluating sin(t) at integer multiples of pi, and therefore sin(t)=0 at each point. Due to round-off error, the values are not exactly zero, but are <10^-12.
@Torsten demonstrates that by changing the values of t, you can see that it is a normal sine wave.

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

범주

Find more on Annotations 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!

Translated by