How to fix: Index Exceeds Matrix Dimensions
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Im new to MATLAB and am trying to extract data from a aerial photo in tif.I keep getting this error:
Index exceeds matrix dimensions.
Error in STASAR>pushbutton2_Callback (line 544)
komp1(k,j)=komp1p(w,1);
And that from this editor:
komp1=zeros(801,801);
komp2=zeros(801,801);
w=0;
for i=1:801
k=801+1-i;
for j=1:801
w=w+1;
komp1(k,j)=komp1p(w,1); error from this line
komp2(k,j)=komp2p(w,1);
end
end
please help me, this is progress in my thesis. Thanks
0 commentaires
Réponses (1)
Abraham Boayue
le 18 Mar 2018
Modifié(e) : Abraham Boayue
le 20 Mar 2018
Hey Ahmad, it looks like you have created more space for the data than you are trying to store in komp1. Komp1 is sized 801 by 801, which means that your data size must be at least 801 by 801. If it is less, say 800 by 800, you will get error of index exceed matrix dimensions. This is because your double for loops were made to run 801 times. Every time they run, one data point is saved, the code will work fine as long as there is something to do. So, in short, you cannot create more space than what you have to work with. Check the size of the data and then make room for it. I don't know what you are trying to achieve with your code, but what are the aims of k and w?
0 commentaires
Voir également
Catégories
En savoir plus sur Matrix Indexing 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!