how do i write sin^2(x) in matlab?
Mostrar comentarios más antiguos
I am trying to plot sin^2(x) together with cos^2(x) between [0,2pi]
but cant get my matlab to accept sin^2(x).
here is what I wrote, what am i doing wrong?
x=0:0.01:2*pi
si=sin^2(x);
co=cos^2(x);
plot(si,co)
5 comentarios
manoj pokhriyal
el 4 de Sept. de 2020
si=(sin(x))^.2
co=(cos(x))^.2
plot(si,co)
manoj pokhriyal
el 4 de Sept. de 2020
sorry my mistake
si=sin(x).^2
co=cos(x).^2
plot(si,co)
Hammad
el 23 de En. de 2024
Movida: Dyuman Joshi
el 23 de En. de 2024
how sin(-5) is equal to 0.9589 in matlab?
That is the correct value for the sine of -5 radians. If you wanted to compute the sine of -5 degrees use the sind function instead of the sin function.
R1 = -5; % radians
D1 = rad2deg(R1) % -5 radians in degrees
sineOfMinus5Radians = [sin(R1); sind(D1)]
D2 = -5; % degrees
R2 = deg2rad(D2) % -5 degrees in radians
sineOfMinus5Degrees = [sind(D2); sin(R2)]
Dyuman Joshi
el 23 de En. de 2024
Editada: Dyuman Joshi
el 23 de En. de 2024
@Hammad, the input of sin() is considered as radian, which can be seen from the documentation of sin (easily foundable by a simple search on the internet), thus the value is provided accordingly.
Also note that the output shown is a truncated value upto 4 digits after decimal, which is not what the actual value is.
Respuesta aceptada
Más respuestas (1)
hemin ahmad
el 18 de Feb. de 2024
0 votos
sin(x)
1 comentario
Walter Roberson
el 18 de Feb. de 2024
No, this is not correct. As explained above, sin(x).^2 is needed.
Categorías
Más información sobre Matrix Indexing en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
