what to do in this case?
Show older comments
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.
Accepted Answer
More Answers (1)
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
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

