MATLAB: Repeat each page of 3d matrix 24 times

3d matrixrepmat

So as part of a script I have:
totmelt(:,:,day)=daymelt2;
Daymelt2 is a 2d matrix, and day is the day of the year (1:365). As it stands I get a 3d matrix with 365 in the 3rd dimension, or 365 pages. But I need the output for each day to be repeated 24times in consecutive pages. So the first 24 pages are the first daymelt2 matrix, the next 24 the the second daymelt2 matrix.
Is there a way I can do this? Without post-processing by extracting every single page and using repmat.
Thank you

Best Answer

Perhaps you want:
totmelt = repmat(daymelt2, 1, 1, 24*365);
Or:
totmelt = zeros(M, N, 24, 365); % With matchin M and N
...
totmelt(:, :, :, day) = repmat(daymelt2, 1, 1, 24);
...
totmelt = reshape(totmelt, M, N, 24*365);