MATLAB: Saving matrix elements into array

matrix arrayurgent

Hi,
I have 9 matrices with size 500×2. I would like to save them into a 3×3 array; i.e. my first 500×2 matrix be the first element of my 3×3 matrix and so on. Can you please help me?

Best Answer

You can use a cell array for this
X = cell(3,3)
X{1,1} = My500by2Matrix1 ;
% etc.

.. or use a 4D matrix
X = zeros(3,3,500,2) ;
X(1,1,:) = My500by2Matrix1 ;
% etc.
% and use squeeze to obtain a particular matrix
squeeze(X(3,2,:,:))