Clear Filters
Clear Filters

Indexing Exceeds number of array elements

2 views (last 30 days)
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.

Accepted Answer

Image Analyst
Image Analyst on 28 Feb 2023
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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!