I'm attempting to plot y(x)=sin^2(a*sin(x))/sin^2(sin(x)), where a is some nonzero constant, but can't generate a plot becuase y is being returned as a constant. y should be a function that varies with x, not a constant numerical value, so what am I doing wrong?
Code:
x=0:10
r=sin(x)
y=sin(3*r).^2/sin(r).^2
plot(x,y)

 Respuesta aceptada

Star Strider
Star Strider el 28 de Feb. de 2020

1 voto

Do element-wise division as well:
y=sin(3*r).^2./sin(r).^2;
↑ ← HERE
That should do what you want.

2 comentarios

Orennia Goetzinger
Orennia Goetzinger el 28 de Feb. de 2020
Thank you!!!
Star Strider
Star Strider el 28 de Feb. de 2020
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 28 de Feb. de 2020

Comentada:

el 28 de Feb. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by