Matrix Dimensions must agree

1 vue (au cours des 30 derniers jours)
Erik Sanabria
Erik Sanabria le 20 Août 2014
Réponse apportée : Ben11 le 20 Août 2014
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!

Réponses (1)

Ben11
Ben11 le 20 Août 2014
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])

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by