フィルターのクリア

How to fix: Index Exceeds Matrix Dimensions

1 回表示 (過去 30 日間)
Ahmad Ali Syafi'i
Ahmad Ali Syafi'i 2018 年 3 月 18 日
編集済み: Abraham Boayue 2018 年 3 月 20 日
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

回答 (1 件)

Abraham Boayue
Abraham Boayue 2018 年 3 月 18 日
編集済み: Abraham Boayue 2018 年 3 月 20 日
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?

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by