Index in position 2 exceeds array bounds. Index must not exceed 7?

4 次查看(过去 30 天)
When I run my program some times work and alot of times got this message and I dont know why:
Index in position 2 exceeds array bounds. Index must not exceed 7.
Error in
N1(1,i)=f(n-j,i+j);
my code is :
N1=f(n,:);
for i=1:size(f,1)
if isnan(N1(1,i))
for j=1:size(f,1)
N1(1,i)=f(n-j,i+j);
if ~isnan(f(n-j,i+j))
break
end
end
end
end

采纳的回答

Rik
Rik 2022-11-17
Since i and j both range from 1 to the number of rows in f, there is no reason i+j will be less than the number of columns in f.
Since you wrote no comments and didn't use understandable variable names, I cannot provide you with a suggestion for a fix.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by