I have created a 20x3xN 3D matrix (where N is a user defined value passed to a function):
LTM = zeros(20,3,N);
I have also created a 20×3 matrix of values by running a function. This is called 'last20Steps'
What I am trying to do is with a while loop iterate through the Z dimension of the 3D matrix (LTM) and populate the 2D matrix into this with each iteration.
iterationNumber = 1while iterationNumber <= N %Function that runs the code to generate the 2D matrix and populate LTM
rndStartState(); iterationNumber = iterationNumber + 1;end
The outcome should be: LTM(:,:,5) should return the 5th iteration of the 20×3 matrix data.
This is what I have been trying:
LTM(:,:,iterationNumber) = last20Steps;
This returns the following error: Subscripted assignment dimension mismatch.
I have tried not defining the size of the LTM and assigning it as LTM = [] which also does not work.
Any help or advice would be appreciated.
Thanks.
Best Answer