MATLAB Answers

Error using / Matrix dimensions must agree

2 views (last 30 days)
Katharine Robbins
Katharine Robbins on 13 Aug 2019
Answered: Torsten on 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);

  0 Comments

Sign in to comment.

Accepted Answer

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

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.

Tags