Indexing Exceeds number of array elements

2 次查看(过去 30 天)
et=4; dn1=1:61;
for ii=length(dn1)
r(ii)=(et+((dn1(ii+1)-dn1(ii))))./((dn1(ii)-(dn1(ii-1)))+et);
end
Index exceeds the number of array elements. Index must not exceed 61.

采纳的回答

Image Analyst
Image Analyst 2023-2-28
Look at your indexes - they go from ii-1 to ii+1 so ii can only go from 2 to length(dn)-1
et=4;
dn1=1:61;
for ii = 2 : length(dn1)-1
r(ii) = (et+((dn1(ii+1)-dn1(ii))))./((dn1(ii)-(dn1(ii-1)))+et);
end

更多回答(0 个)

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by