MATLAB Answers

0

Attempt to grow array along ambiguous dimension

Asked by kirti kaushal on 15 Feb 2018
Latest activity Answered by Walter Roberson
on 15 Feb 2018
error in my code is: my code is running for some images but not for some images. temp_x{n1}(ind_count) = x(n2);
my opengl info is: Version: '1.1.0' Vendor: 'Microsoft Corporation' Renderer: 'GDI Generic' MaxTextureSize: 1024 Visual: 'Visual 0x23, (RGB 24 bits (8 8 8), Z depth 16 bits, Software, Single buffer, Antialias 0 samples)' Software: 'true' HardwareSupportLevel: 'none (known graphics driver issues)' SupportsGraphicsSmoothing: 0 SupportsDepthPeelTransparency: 0 SupportsAlignVertexCenters: 0 Extensions: {3×1 cell} MaxFrameBufferSize: 0

  0 Comments

Sign in to comment.

1 Answer

Answer by Walter Roberson
on 15 Feb 2018

Your opengl turns out to not be relevant to this.
You have a 2d or 3d array. You are assigning into the array using a single subscript, so that means you are using linear indices. Some of the target indices being assigned to are larger than the number of elements in the array, so MATLAB needs to grow the array. But which dimension should it grow the array on? Add more rows? Add more columns? Add more to the third dimension? Start into the next dimension beyond the existing ones? MATLAB does not have a rule for which dimension to expand when you attempt to assign to a linear index beyond the end of an array that is not a vector (vector is well defined for this) so it gives you the ambiguous dimension error.
If you are deliberately expanding the matrix then translate the linear indices into row and column references so that MATLAB can see which dimension is being grown.

  0 Comments

Sign in to comment.