Matrix Dimensions must agree

Here is a simple function I have to plot for a course in Matlab:
x = [0:0.01:10];
gx = 1-(2/x.^2);
plot(x,gx);
axis([-1,12,-1,12])
When I run it I get this error message:
Error using / Matrix dimensions must agree.
Please help!

Respuestas (1)

Ben11
Ben11 el 20 de Ag. de 2014

2 votos

You're missing a "." in your division:
x = [0:0.01:10];
gx = 1-(2./x.^2);
plot(x,gx);
axis([-1,12,-1,12])

Categorías

Más información sobre Programming en Centro de ayuda y File Exchange.

Productos

Preguntada:

el 20 de Ag. de 2014

Respondida:

el 20 de Ag. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by