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

4 次查看(过去 30 天)
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.

采纳的回答

Stephen23
Stephen23 2022-9-22
编辑:Stephen23 2022-9-22
"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 个评论
Krishan Bansal
Krishan Bansal 2022-9-22
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.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by