I am trying to set up a parfor nested loop in MatLab R2020a as below
function [stiffness, mass] = assemble(stiffness, mass, k, m, index)edof = length(index);parfor i = 1:edof ii = index(i); for j = 1:edof jj = index(j); stiffness(ii, jj) = stiffness(ii, jj) + k(i, j); mass(ii, jj) = mass(ii, jj) + m(i, j); endend
The code analyzer returns this message: "Valid indices for 'stiffness' are restricted in parfor loops".
and the command window said: "Unable to classify the variable 'stiffness' in the body of the parfor-loop".
I am really appreciate if somone could explain the problem to me. Thank you very much!
Best Answer