Filling in a 2-D matrix slice by slice with parfor
1 view (last 30 days)
Show older comments
Hi,
I have a 2-d matrix where one dimension is a unique starting state, the second is time, and I need to compute entries in this matrix. Given the starting state, the evolution in time follows a recursive formula. For instance:
A = zeros(1000,1000);
A(:,1) = 1;
for i = 1:1000
for t = 2:1000
A(i,t) = 1 + A(i,t-1);
end
end
In the actual application there is no way around the recursive formulation in the t dimension. I would like to replace the outer loop with parfor, but I get an error since A(i,t-1) appears on the RHS of the assignment operator. Conceptually the slices in the i dimension are independent so it should be possible to parallelize.
Any advice on how to implement parfor?
0 Comments
See Also
Categories
Find more on Data Type Identification 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!