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 comentarios

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

Iniciar sesión para comentar.

 Respuesta aceptada

Stephen23
Stephen23 el 6 de Nov. de 2018
Editada: Stephen23 el 6 de Nov. de 2018

0 votos

"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).

Más respuestas (0)

Categorías

Más información sobre Testing Frameworks en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 6 de Nov. de 2018

Comentada:

el 6 de Nov. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by