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 Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by