Why am I getting the error "Array indices must be positive integers or logical values"?
1 回表示 (過去 30 日間)
古いコメントを表示
I have the following code. I am unsure as to why I am recieving this error when the array indices is always positive as far as I can tell.
function[f] = ntdd(x,f)
n = length(f);
for i = 2:n
for j = n:-1:1
f(j) = ((f(j)-f(j-1))/(x(j)-x(j-(i+1))));
end
end
end
3 件のコメント
madhan ravi
2019 年 2 月 12 日
If you illustrate with an example and your desired output it would be clear what you are doing.
採用された回答
Kevin Phung
2019 年 2 月 12 日
for i = 2:n
for j = n:-1:1
f(j) = ((f(j)-f(j-1))/(x(j)-x(j-(i+1))));
end
end
looks like when j is 1, you have a f(j-1) which gives you f(0)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!