Error using / Matrix dimensions must agree

1 vue (au cours des 30 derniers jours)
Katharine Robbins
Katharine Robbins le 13 Août 2019
Réponse apportée : Torsten le 13 Août 2019
This is my script (named partf):
x = 2;
h = 10.0.^-(1:10);
fp = (1/(x + h) - 2*(1/x) + 1/(x - h)) ./(h^2);
er = abs(fp - 2/(x^3))
I do not know why I am getting this error, and what it means:
Error using /
Matrix dimensions must agree.
Error in partf (line 3)
fp = (1/(x + h) - 2*(1/x) + 1/(x - h)) ./(h^2);

Réponse acceptée

Torsten
Torsten le 13 Août 2019
fp = (1./(x + h) - 2*(1/x) + 1./(x - h)) ./h.^2;

Plus de réponses (0)

Catégories

En savoir plus sur Multidimensional Arrays dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by