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

조회 수: 4 (최근 30일)
Krishan Bansal
Krishan Bansal 2022년 9월 22일
댓글: Krishan Bansal 2022년 9월 22일
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