Index exceeds matrix dimensions, error problem
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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?
0 commentaires
Réponses (3)
Star Strider
le 7 Juin 2014
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.
0 commentaires
SRI
le 7 Juin 2014
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
0 commentaires
chaima kadess
le 8 Avr 2018
I also faced the same error with this ligne ?? I= dicomread(fileNames{numFrames});
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!