In parfor , why a variable cannot be classified?
Show older comments
In the code below I get an error
Error: The variable Matrix in a parfor cannot be classified.See Parallel for Loops in MATLAB, "Overview".
parfor i=1:n
try
query = 'SELECT * FROM TABLE WHERE Criterion = '' criteria(i) ''';
curs = exec(conn, query);
curs = fetch(curs);
close(curs);
results = curs.Data;
A = f(results);
B = g(results);
C = h(results);
D = k(results);
Matrix(i,6:9) = horzcat(A,B,C,B);
catch
Matrix(i,6:9) = {0,0,0,0};
end
end
Any ideas what I am missing?
2 Comments
Walter Roberson
on 2 Jul 2015
Do A, B, C, D come out as cell arrays? At the moment it looks plausible that you have storing a numeric vector in one case and a vector of cells in the other case.
sm
on 2 Jul 2015
Accepted Answer
More Answers (1)
Brendan Hamm
on 2 Jul 2015
Preallocate your matrix before the loop:
Matrix = nan(n,9)
Although lookingat your catch statement is Matrix a cell array? That is confusing.
1 Comment
sm
on 2 Jul 2015
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!