MATLAB Answers

0

Index exceeds matrix dimensions.

Yasmin Samy さんによって質問されました 2017 年 11 月 4 日
最新アクティビティ Stephen Cobeldick
さんによって 編集されました 2017 年 11 月 4 日
Hello! The code below shows two sections for deleting rows according to two conditions. They are exactly the same but for some reason i get the 'Index exceeds matrix dimensions' error. Any idea what am i missing here?
aod_siglowp = mean_aodcoarsePEARL - (3*sigaodPEARL);
aod_sighighp = mean_aodcoarsePEARL +(3*sigaodPEARL);
reff_siglowp = mean_reffcoarsePEARL - (3*sigma_p(1,2));
reff_sighighp = mean_reffcoarsePEARL + (3*sigma_p(1,2));
coarsep_aod = cp(:,1);
cond1_aod = coarsep_aod(:,1) > aod_sighighp;
cond2_aod = coarsep_aod(:,1) < aod_siglowp;
delerowsaod = or(cond1_aod,cond2_aod);
coarsep_aod(delerowsaod,:)=[];
coarsep_reff = cp(:,2);
cond1_reff = coarsep_reff(:,1) > reff_sighighp;
cond2_reff = coarsep_reff(:,1) < reff_siglowp;
deleterows2 = or(cond1_reff,cond2_reff);
coarsep_reff(deleterows2,:)=[];
when entering the second section line by line...the line below is where i get the error (combining the two logical conditions to be able to delete the rows)
>>deleterows2 = or(cond1_reff,cond2_reff);
Index exceeds matrix dimensions.

  5 件のコメント

Stephen Cobeldick
2017 年 11 月 4 日
You cannot make the text red on this forum. You need to copy all of the red text from the MATLAB command window, because the complete error message has information that is useful in diagnosing the problem. Beginners sometimes do not give us the complete error message, which makes it harder for us to help them.
Yasmin Samy 2017 年 11 月 4 日
Thanks Stephen. I have copied the error message exactly. However, i did another rerun again,and this time i got no error. I`m still not sure what happened. However, if someone can explain why sometimes this error appears, that would be appreciated. I`m thinking it could be because of the type ..table, array etc??
Stephen Cobeldick
2017 年 11 月 4 日
@Yasmin Samy: is the code in a script or a function? If it is in a script then sometimes these kind of errors occur because of some variable in the workspace that doe snot changes between runs ... the best solution is to write functions.

サインイン to comment.

0 件の回答


Translated by