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.

 Réponse acceptée

VBBV
VBBV le 23 Oct 2022

0 votes

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 commentaires

VBBV
VBBV le 23 Oct 2022
Or use fimplicit function
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 le 23 Oct 2022
Modifié(e) : VBBV le 23 Oct 2022
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 ?

Connectez-vous pour commenter.

Plus de réponses (1)

John D'Errico
John D'Errico le 23 Oct 2022
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

Catégories

En savoir plus sur Line Plots dans Centre d'aide et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by