Error using / Matrix dimensions must agree

1 Ansicht (letzte 30 Tage)
Katharine Robbins
Katharine Robbins am 13 Aug. 2019
Beantwortet: Torsten am 13 Aug. 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);

Akzeptierte Antwort

Torsten
Torsten am 13 Aug. 2019
fp = (1./(x + h) - 2*(1/x) + 1./(x - h)) ./h.^2;

Weitere Antworten (0)

Kategorien

Mehr zu Multidimensional Arrays finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by