subplot (4,1,1)
fplot (@(x, y = 1) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1]);
subplot (4,1,2)
fplot (@(x, y = 0.7) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1]);
subplot (4,1,3)
fplot (@(x, y = 0.5) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1]);
subplot (4,1,4)
fplot (@(x, y == 0.1) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1]);
fplot (@(x, y = 1) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1]);
Error: Unsupported use of the '=' operator. To compare values for equality, use '=='.
To specify name-value arguments, check that name is a valid identifier with no
surrounding quotes.

 採用された回答

VBBV
VBBV 2022 年 10 月 23 日

0 投票

fplot (@(x, y) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1, 0, 1]);
Give the values of y range just like x

3 件のコメント

VBBV
VBBV 2022 年 10 月 23 日
Or use fimplicit function
VBBV
VBBV 2022 年 10 月 23 日
subplot (4,1,1)
fimplicit(@(x, y) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1 0 1]);
subplot (4,1,2)
fimplicit(@(x, y) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1 0 0.7]);
subplot (4,1,3)
fimplicit(@(x, y) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1, 0 0.5]);
subplot (4,1,4)
fimplicit(@(x, y) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1, 0 0.1]);
fimplicit(@(x, y) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1 0 1]);
VBBV
VBBV 2022 年 10 月 23 日
編集済み: VBBV 2022 年 10 月 23 日
y = [1 0.7 0.5 0.1 1]
y = 1×5
1.0000 0.7000 0.5000 0.1000 1.0000
%subplot (4,1,1)
fplot (@(x) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1]);
legend('y = 1','y = 0.7','y = 0.5','y = 0.1','y = 1')
you can also plot using single fplot function since you are looking specific y value, btw, what is difference in first and last y values, if you have same function for same defined x range ?

サインインしてコメントする。

その他の回答 (1 件)

John D'Errico
John D'Errico 2022 年 10 月 23 日

0 投票

You cannot set a variable to have a value inside another statement.
For example, this line of code would not be valid in MATLAB
x = 2 + y = 3;
Would you expect that to set y to the value 3, and then add 2 to y, to get x as 5?
Similarly, this is also invalid:
fplot (@(x, y = 1) x.^3.*y-2.*x.*y.^2+y-0.2,[0, 1]);
Again, you cannot set y to a value in the middle of another statement.
If you need to give y the value of 1, then 2, then 3 and 4, so plotting that relationship, where y takes on specific values, you might do this, instead:
yvals = [1 2 3 4];
ny = numel(yvals);
for ind = 1:ny
subplot(ny,1,ind)
fxy = @(x,y) x.^3.*y-2.*x.*y.^2+y-0.2;
fplot(@(x) fxy(x,yvals(ind)),[0,1])
end

カテゴリ

ヘルプ センター および File ExchangeLine Plots についてさらに検索

タグ

質問済み:

2022 年 10 月 23 日

編集済み:

2022 年 10 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by