Repeat each page of 3d matrix 24 times
Show older comments
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
2 Comments
Walter Roberson
on 29 Apr 2013
So you want the output to be size(daymelt2,1) x size(daymelt2,2) x 365 x 24 ? Or size(daymelt2,1) x size(daymelt2,2) x (365*24) ?
Grant
on 29 Apr 2013
Accepted Answer
More Answers (1)
Andrei Bobrov
on 29 Apr 2013
out = totmelt( :,:,kron(1:size(totmelt,2), ones(1,24)) );
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!