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

3 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2019-11-6
bestPatchMatchTempD is a 131x98x84 singles (an mri-image)
I suspect that at least one of your images is smaller than that.

请先登录,再进行评论。

回答(1 个)

Steven Lord
Steven Lord 2019-11-6
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 个评论
Anders Jensen
Anders Jensen 2019-11-6
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by