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

3 visualizaciones (últimos 30 días)
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 comentario
Walter Roberson
Walter Roberson el 6 de Nov. de 2019
bestPatchMatchTempD is a 131x98x84 singles (an mri-image)
I suspect that at least one of your images is smaller than that.

Iniciar sesión para comentar.

Respuestas (1)

Steven Lord
Steven Lord el 6 de Nov. de 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 comentario
Anders Jensen
Anders Jensen el 6 de Nov. de 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.

Iniciar sesión para comentar.

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by