MATLAB: Compute the mean of matrices with different dimensions

image processingImage Processing Toolboxmatrix arraymatrix manipulation

I have three matrices of dimensions: matrixA: [2730 512], matrixB: [2730 512], and matrixC: [2730 256]. How do I reshape matrixC to [2730 512] by filling empty cells with zeros and compute the average of the three matrices so that the resultant matrix will be of dimension [2730 512]?

Best Answer

Z = nan(2370,512,3);
Z(:,1:512,1) = A;
Z(:,1:512,2) = B;
Z(:,1:256,3) = C;
mean(Z,3)