Error using / Matrix dimensions must agree

조회 수: 1 (최근 30일)
Katharine Robbins
Katharine Robbins 2019년 8월 13일
답변: Torsten 2019년 8월 13일
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);

채택된 답변

Torsten
Torsten 2019년 8월 13일
fp = (1./(x + h) - 2*(1/x) + 1./(x - h)) ./h.^2;

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multidimensional Arrays에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by