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 Center および File ExchangeMultidimensional Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by