Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Hi, so I'm trying to plot this equation: y=-(sqrt(288-2*x.^4))/x with x=0:0.05:3.267 but y is giving me a single answer (-6.55) and when i do plot(x,y) the graph is empty! Can someone help me please!

1 回表示 (過去 30 日間)
Seamus Pugh
Seamus Pugh 2016 年 2 月 29 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi, so I'm trying to plot this equation: y=-(sqrt(288-2*x.^4))/x with x=0:0.05:3.267 but y is giving me a single answer (-6.55) and when i do plot(x,y) the graph is empty! Can someone help me please!

回答 (3 件)

Ingrid
Ingrid 2016 年 2 月 29 日
you have forgotten to also use the ./ operator instead of the / operator. The code below should give what you try to achieve
x=0:0.05:3.267;
y=-(sqrt(288-2*x.^4))./x;
plot(x,y)

Torsten
Torsten 2016 年 2 月 29 日
You forgot a dot (.) in front of "/x".
Best wishes
Torsten.

Jos (10584)
Jos (10584) 2016 年 2 月 29 日
The plot is not empty. It contains 66 points all having the same y value (at y=-6.5514), which can be seen here:
plot(x,y,'bo')
Why is y a scalar? Because, as others told you already, there is a difference between element-wise (.* and ./) and matrix operators (* and /):
x = 1:4
x ./ x
x / x

この質問は閉じられています。

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by