In MATLAB, I can grow a variable by indexing out of bounds. By default, MATLAB will fill out any missing entries with zeros (as in the case of a numerical array). For example:
x = 1;x(3,3) = 1x = 1 0 0 0 0 0 0 0 1
When I try to generate code from such a function using MATLAB Coder, I receive an error:
??? Index expression out of bounds. Attempted to access element 3. The valid range is 1-1.
Is there any way to work around this?
Best Answer