Need help plotting simple graph in matlab

AI Thread Summary
The user is attempting to plot a graph in MATLAB using the equation I = V^3 - 1.4*V + 0.9 but encounters an error due to incorrect matrix operations. The error message indicates that matrix multiplication is being improperly applied. The solution involves using element-wise operations by replacing the power operator with the dot operator, resulting in I = (V.^3) - (1.4*V) + 0.9. After making this adjustment, the plot command should work correctly. This approach resolves the matrix dimension issue and allows for successful graph plotting.
Fairy111
Messages
72
Reaction score
0

Homework Statement


I need to plot a graph in matlab,
i typed in the following,
V=[0:.2:20];
I=(V^3)-(1.4*V)+0.9;
plot(V,I)

It comes up with the error,
error using mpower, matrix must be square.

Any help into how to fix this problem would be great.

Thankyou



Homework Equations





The Attempt at a Solution

 
Physics news on Phys.org
A^2 = A*A, i.e. a matrix multiplication. Use A.^2 for element-wise operations:

V=[0:.2:20];
I=(V.^3)-(1.4*V)+0.9;
plot(V,I)

Ought to work.
 
Back
Top