What is f ? And how big is it?
How to fix index in a parfoor loop?
1 view (last 30 days)
Show older comments
Andreu Angles Castillo on 13 Sep 2018
Commented: Andreu Angles Castillo on 18 Sep 2018
I have the following code and get indexing error
A(dm+1,dt+1) = f(dm,dt);
It does not make sense, for me, because each loop of the first for is stand alone in the variable dt. The size of A has been prefixed.
The error messages on the script are:
-The PARFOOR loop cannot run due to the way varaiable 'A' is used. (On line 1)
-Valid indices for 'A' are resticted in PARFOR loops. (On line 4)
Error when run:
Error: The variable A in a parfor cannot be classified. See Parallel for Loops in MATLAB, "Overview".
Titus Edelhofer on 14 Sep 2018
agreed, it looks as if this case could be handled. But it is fairly easy to work around this by separating the inner loop from the parfor loop:
n = round(tmax/step) + 1;
col = zeros(n, 1);
col(dm+1) = f(dm, dt);
A(:, dt+1) = col;
More Answers (0)
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!