Filter löschen
Filter löschen

How to fix: Index Exceeds Matrix Dimensions

1 Ansicht (letzte 30 Tage)
Ahmad Ali Syafi'i
Ahmad Ali Syafi'i am 18 Mär. 2018
Bearbeitet: Abraham Boayue am 20 Mär. 2018
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

Antworten (1)

Abraham Boayue
Abraham Boayue am 18 Mär. 2018
Bearbeitet: Abraham Boayue am 20 Mär. 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?

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by