Hey all, i'm trying to plot the contours of constant e=0, 0.1, 0.2, 0.3 and 0.4 using the parametric expression of
x=e*cos(theta)/sqrt(4/3+4/3*cos(theta)*sin(theta) , y=e*sin(theta)/sqrt(4/3+4/3*cos(theta)*sin(theta))
---------------------------------------------------------------------------------------------------------------------------------------
I tried it like this, but got errors on dimension.
When i tried on ,for example, e=0.1 case,
theta=0:0.1:(2*pi);
e=0.1;
x=e*cos(theta)/sqrt(4/3+4/3*cos(theta)*sin(theta));
y=e*sin(theta)/sqrt(4/3+4/3*cos(theta)*sin(theta));
plot(x,y)
then, i got error message about dimension errors in matrix multiplication. Could you help me on this ?
and my last question is, Is there a way to change only the e-values and show them all in one picture?
Thank you

 採用された回答

Star Strider
Star Strider 2020 年 5 月 29 日
編集済み: Star Strider 2020 年 5 月 29 日

0 投票

Use element-wise operations (the ‘dot operator’):
x=e*cos(theta)./sqrt(4/3+4/3*cos(theta).*sin(theta));
y=e*sin(theta)./sqrt(4/3+4/3*cos(theta).*sin(theta));
That worked when I ran it.
EDIT —
You can plot them all at the same time (without loops) by using matrix operations as well as element-wise (array) operations:
theta=0:0.1:(2*pi);
e=[0.1; 0.2; 0.3; 0.4];
x=e*cos(theta)./sqrt(4/3+4/3*cos(theta).*sin(theta));
y=e*sin(theta)./sqrt(4/3+4/3*cos(theta).*sin(theta));
plot(x.',y.')
.

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で 2-D and 3-D Plots についてさらに検索

質問済み:

2020 年 5 月 29 日

編集済み:

2020 年 5 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by