Filter löschen
Filter löschen

subscript dimension error warning

2 Ansichten (letzte 30 Tage)
Osita Onyejekwe
Osita Onyejekwe am 29 Jul. 2016
Beantwortet: Walter Roberson am 30 Jul. 2016
I keep getting this error,
Subscripted assignment dimension mismatch.
Error in FCN_ECG_PLOTS (line 77)
bwmap(i, iNoise)= bw(idx); % % with the index we find what the actual bandwidth value
is.
The portion of the code goes like this , (the function is where the error occurs)
for i= 1:N
mx= max(SNR(i,:, iNoise)) ;
idx=find(SNR(i,:, iNoise)==mx);
*bwmap(i, iNoise)= bw(idx);*** this is where it dies
.
.
.
end
note that when i use bw = 0.1:0.1:0.5 it works PERFECTLY but when I use bw= 0.001:0.001:0.005; i get that error, this makes NO sense..why?!! i need to use the second bw not the first one (different data)

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 30 Jul. 2016
find() will return multiple locations if there are multiple matches. That is, you are encountering a situation in which two locations contain the identical maximum value. In fact, the only reason to do those operations on two different lines is for the case where you expect there to be multiple locations with the same maximum and you either want to know them all or else you want control over which of the locations with identical values is selected.
If you just want to know one of the locations and do not care which then combine the two lines:
[mx, idx] = max(SNR(i,:, iNoise));
bwmap(i, iNoise)= bw(idx);

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by