Sine Function I'm trying to Plot won't show up

8 visualizaciones (últimos 30 días)
Krishan Bansal
Krishan Bansal el 22 de Sept. de 2022
Comentada: Krishan Bansal el 22 de Sept. de 2022
I am trying to plot the sine based function with various constants. However, when I try to plot them nothing shows up in the figure window, and the variables in the workspace only evaluate to one number rather than the whole range of phi. Not sure what I'm doing wrong here.

Respuesta aceptada

Stephen23
Stephen23 el 22 de Sept. de 2022
Editada: Stephen23 el 22 de Sept. de 2022
"Not sure what I'm doing wrong here."
You need to use element-wise division, not matrix division:
phi = 0:0.1:6*pi;
I2 = sin(phi).^2 ./ sin(phi/2).^2;
% ^^
plot(I2)
Tip: if you are not doing linear algebra you probably should be using array operations:
  1 comentario
Krishan Bansal
Krishan Bansal el 22 de Sept. de 2022
Thanks! I had a feeling it had something to do with that! I always forget to do .*, I'm surprised I forgot here because I specifically did element wise squaring.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by