The logical indices contain a true value outside of the array bounds

10 visualizzazioni (ultimi 30 giorni)
Hi.
I have the problem: "The logical indices contain a true value outside of the array bounds" in this code:
crsPatch{c,ii} = bestPatchMatchTempD(crsPatchMasks{c,ii});
  • Where crsPatch is a 6x5 cell array containing 27x1 singles
  • bestPatchMatchTempD is a 131x98x84 singles (an mri-image)
  • crsPatchMasks is a 6x5 cell array containing 131x98x84 logical
In my main, I am able to run this code about 43000 times out of 47000 - and then the error comes. Anyone familiar with this problem?
In advance, thanks!
  1 Commento
Walter Roberson
Walter Roberson il 6 Nov 2019
bestPatchMatchTempD is a 131x98x84 singles (an mri-image)
I suspect that at least one of your images is smaller than that.

Accedi per commentare.

Risposte (1)

Steven Lord
Steven Lord il 6 Nov 2019
I recommend setting an error breakpoint and running your code again. When the code throws the error and stops at the breakpoint, check that your variables are the sizes and data types you expect them to be and check that they have reasonable values for your application.
If I had to guess I'd say that c is a logical array with more than 6 elements, and one of the elements past the sixth is true when you didn't expect it to be, so the indexing into crsPatchMasks fails. ii is probably a loop variable, which are usually double precision, and if that took on a value greater than 5 you would have received a different error.
  1 Commento
Anders Jensen
Anders Jensen il 6 Nov 2019
Thanks for the answer. I still cant figure the error out :-(
6×5 cell array
{27×1 single} {27×1 single} {27×1 single} {27×1 single} {27×1 single}
{27×1 single} {27×1 single} {27×1 single} {27×1 single} {27×1 single}
{27×1 single} {27×1 single} {27×1 single} {27×1 single} {27×1 single}
{27×1 single} {27×1 single} {27×1 single} {27×1 single} {27×1 single}
{27×1 single} {27×1 single} {27×1 single} {27×1 single} {27×1 single}
{ 0×0 double} { 0×0 double} { 0×0 double} { 0×0 double} { 0×0 double}
The values in the last cell seems correct.

Accedi per commentare.

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by