Graphing as a function of Y
Ältere Kommentare anzeigen
I want to use the function plot to plot the right-side of the equation f(y) = −2 + 5*y^2 − y*5 on the interval −2 ≤ y ≤ 2 (with y on horizontal axis).
The error message reads:
Error in assignment (line 1)
x = -2+5*y^2-y^5
How do I fix this?
x = -2+5*y^2-y^5
ylim([-2 -2])
plot (y,x)
1 Kommentar
Bjorn Gustavsson
am 23 Sep. 2019
If you have y as an array (either [n x 1] or [1 x n]) then matlab treats the operations * ^ as matrix-operations, for your case that means that y^2 and y^5 as matrix powers. You most likely want the element-wise power. In matlab that is written as y.^2 etc.
HTH
Antworten (1)
Kategorien
Mehr zu Plot Settings finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!