I'm using parfor
, unfortunately two of my variables, x
and y
, which are both matrices, get broadcasted and don't know how to avoid it. I've read about it in the MATLAB help, but couldn't figure out a solution. How can I prevent broadcasting of x
and y
?
Here is my code :
parfor k=1:length(Lambda)
lambda=Lambda(k);
for p=1:length(Gamma)
gamma=Gamma(p);
for Fold=1:size(Fold_indices,2)
x_Train=x(logical(Fold_indices(:,Fold)),1:end);
Y_Train=y(logical(Fold_indices(:,Fold)),1:Num_Tasks);
% Do sth with x_Train and Y_train
end
end
end
I've tried to slice broadcasted data(x) into a cell array and it didn't solve the problem a well.
B=cell(1,J);
% Fill each entry of B with a matrix
% ...do it here
....
parfor k=1:length(Lambda)
lambda=Lambda(k);
for p=1:length(Gamma)
gamma=Gamma(p);
for Fold=1:J)
x_Train=B{1,J};
% Do sth with x_Train and Y_train
end
end
end
Interestingly, when I assign the broadacaste variable(B) to other varible(D), then it stops getting brodcated.
B=cell(1,J);
% Fill each entry of B with a matrix
% ...do it here
....
parfor k=1:length(Lambda)
D=B;
lambda=Lambda(k);
for p=1:length(Gamma)
gamma=Gamma(p);
for Fold=1:J)
x_Train=B{1,J};
% Do sth with x_Train and Y_train
end
end
end