Nested / parfor loop issue
Show older comments
I am currently trying to run a loop while concurrently running another loop. However, the two different loops do not match in terms of stepping which is giving me some issues.
For example, let's say I have a matrix January, with dimensions (24,6,31) for 24 hours, 6 columns of data, and 31 days that is empty. I want to put data into this matrix from a master matrix, that is 744 x 6 (744 hours in the month of January with the 6 columns of data).
Now, to simply put the first days worth of data into the January matrix, I have: January(:,:,1) = Master(1:24,1:6) The second day would be: January(:,:,2) = Master(25:48,1:6) etc. etc.
What would be the easiest way to loop through this? I have..
January = zeros(24,6,31); for i = 1:24:744 for j = 1:31 January(:,:,j) = Data(i:i+23,1:6); end end
But, this is obviously not correct. Using the parfor function gives me an error because the step between i and j are not the same. Any help would be greatly appreciated!
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements 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!