parfor sometimes throws out "Subscripted Assignment Dimension Mismatch"

I've been using the following code to produce a table using parfor, and while it seems to work fine on my dual-core computer with two workers, using it on the HPC with 12 workers causes "Subscripted Assignment Dimension Mismatch" to occur. Does the difference in workers cause this error or is there another error in the code, and if so, how should I rectify this?
parfor t = startfile:endfile;
textFileName = ['results_' num2str(t-1) '.mat'];
x = load(textFileName);
modposition = x.modposition;
linvellen = x.linvellen;
angvellen = x.angvellen;
num = (numel(modposition))/3;
i = 1:num;
p = double(int16((modposition(i,1)-0.0015)/0.01));
[a,b] = hist(p,unique(p));
b = b+51;
b = b(b.*(b<400)~=0);
a = a(b.*(b<400)~=0);
A = zeros(400,1);
A(b) = a;
P(:,t) = A;
v = double(int16(linvellen(i,1)/0.01));
[a,b] = hist(v,unique(v));
b = b+1;
b = b(b.*(b<500)~=0);
a = a(b.*(b<500)~=0);
B = zeros(500,1);
B(b) = a;
V(:,t) = B;
r = double(int16(angvellen(i,1)));
[a,b] = hist(r,unique(r));
b = b+1;
b = b(b.*(b<500)~=0);
a = a(b.*(b<500)~=0);
C = zeros(500,1);
C(b) = a;
R(:,t) = C;
end

Answers (0)

This question is closed.

Products

Tags

Asked:

on 15 Jul 2016

Closed:

on 20 Aug 2021

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!