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 个评论

sin needs inputs in radians.....if you have input in degrees use sind.
@Fernando Olivares: please do not close questions that have answers.

请先登录,再进行评论。

 采纳的回答

Stephen23
Stephen23 2018-11-6
编辑:Stephen23 2018-11-6
"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 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by