MATLAB: How to put matrices with different sizes together

concatenate matricesdifferent size matricesstocks

I have 20 matrices with sizes = (No of stocks x 12) for 20 years. In each year, the number of stocks is different that the 20 matrices have different sizes. I need to do the same thing with data of each year. Is there anyway that I can put all matrices together and run loop? (so that I don't have write the same code for each year separately)

Best Answer

Ha - consider using a cell array to store the differently sized matrices. Then, you can iterate over each matrix in the cell array and perform whatever operation against each one.