필터 지우기
필터 지우기

Index exceeds matrix dimensions, error problem

조회 수: 3 (최근 30일)
Grace
Grace 2014년 6월 7일
답변: chaima kadess 2018년 4월 8일
function cut=UDcutcut(n,s,p)
initial=[ 1 3;2 6; 3 2; 4 5; 5 1; 6 4; 7 7];
[r s]=size(initial);
new_initial=cell(s,1);
UT=cell(s,r);
for col=1:s
temp=sortrows(initial,col);
new_inital{col}=temp;
for m=1:p
if m>n
UT{col,m}=new_initial{col}(m-n:m-1,:);
else
j=1:m-1;
a=new_initial{col}(j,:);
i=m:n;
b=new_initial{col}(i+p-n,:);
UT{col,m}=cat(1,a,b);
end
end
end
cut=UT;
end
When I run the code, the programme shows me:
>> UDcutcut(4,2,7)
Index exceeds matrix dimensions.
Error in UDcutcut (line 17)
b=new_initial{col}(i+p-n,:);
I can't figure it out where is the problem, anyone help?

답변 (3개)

Star Strider
Star Strider 2014년 6월 7일
I can tell you what’s wrong, but only you know how to fix them:
On the first iteration of the ‘j’ loop, m=1, so j can’t go from 1 to zero unless you tell it to decrement. So j is empty.
In the line throwing the error that assigns b, i is a (1x4) vector that in this situation isn’t allowed as a subscript defining b,a scalar.
They may be other problems, but you have to fix these first to get your code to run.

SRI
SRI 2014년 6월 7일
Check For the size of the m and n which may exceeds the level beyond the loop, so you face this error. instead try changing range for m it may result better

chaima kadess
chaima kadess 2018년 4월 8일
I also faced the same error with this ligne ?? I= dicomread(fileNames{numFrames});

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by