Index exceeds matrix dimensions.
Mostra commenti meno recenti
Daily 10*10 grid precipitation data of 6 days (10*10*6) includes NaN, zeros and negative values. We are trying to replace the NaN values with surrounding cell values.The below script is giving two errors and could not fix it, ("Subscript indices must either be real positive integers or logical") ("Index exceeds matrix dimensions") And the script is as
for i = 2:10;
for j = 2:10;
for k = 2:6;
if isnan(tstsample(i,j,k))
tmp = tstsample(i-1:i+1,j-1:j+1,k);
tstsample(i,j,k) = nanmean(tmp);
end
end
end
end
Need help to solve these issues. I found few materials but not exact one https://ch.mathworks.com/matlabcentral/answers/120517-index-exceeds-matrix-dimensions-error
Thank you in advance
Risposta accettata
Più risposte (1)
Walter Roberson
il 1 Mag 2018
Modificato: Walter Roberson
il 2 Mag 2018
0 voti
3 Commenti
Shakir Hussain
il 2 Mag 2018
Modificato: Walter Roberson
il 2 Mag 2018
Walter Roberson
il 2 Mag 2018
The point was to use one of Jan's solutions posted there.
Walter Roberson
il 11 Mag 2020
This has no connection to the current Question, and should be posted as its own Question.
a = rgb2gray(a);
You convert rgb image, a to gray, and you replace a with that gray image.
a_g = a( :, :, 2 );
Now you want to access the green plane of the gray image you just created.
Perhaps you should extract the green before converting to gray. Or perhaps you should use a different variable name for the gray image so that you still have the rgb available if you need it.
Categorie
Scopri di più su Data Preprocessing in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

