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)

 채택된 답변

Star Strider
Star Strider 2020년 2월 28일

1 개 추천

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

댓글 수: 2

Orennia Goetzinger
Orennia Goetzinger 2020년 2월 28일
Thank you!!!
Star Strider
Star Strider 2020년 2월 28일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2020년 2월 28일

댓글:

2020년 2월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by