So i´m doing the following:
t = [0:0.5:5];
f = 2;
pha = pi/3;
x=sin(2 * pi * f * t + pha);
plot(t,x)
and the result on x will be
I´m pretty sure it´s my fault because i´m quite new, but i have already finished harder exercises and i just can´t find my mistake in this one. Any thoughts?

댓글 수: 2

KSSV
KSSV 2018년 11월 6일
sin needs inputs in radians.....if you have input in degrees use sind.
Stephen23
Stephen23 2018년 11월 6일
@Fernando Olivares: please do not close questions that have answers.

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

 채택된 답변

Stephen23
Stephen23 2018년 11월 6일
편집: Stephen23 2018년 11월 6일

0 개 추천

"Strange problem with sin."
So what is the problem? You did not tell us what you expect to get for the output values, or describe what the supposed "problem" is. We cannot guess what you imagine the output should be.
However what is clear is that sin has correctly calculated the sine values of the input values that you have given it, which have a step of 2*pi:
>> 2 * pi * f * t + pha
ans =
1.0472 7.3304 13.6136 19.8968 26.1799 32.4631 38.7463 45.0295 51.3127 57.5959 63.8791
>> diff(2 * pi * f * t + pha)
ans =
6.2832 6.2832 6.2832 6.2832 6.2832 6.2832 6.2832 6.2832 6.2832 6.2832
>> diff(2 * pi * f * t + pha)/2/pi
ans =
1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000
All you have shown is that every 2*pi of its input sine's output repeats, which is exactly what we would expect (and is by definition of a circle).

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Testing Frameworks에 대해 자세히 알아보기

태그

질문:

2018년 11월 6일

댓글:

2018년 11월 6일

Community Treasure Hunt

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

Start Hunting!

Translated by