MATLAB: How to assign each row of a matrix to a field of a structured array without a loop

assignmatrixstruct

empty_individual.pos=[];
empty_individual.fit=[];
pop=repmat(empty_individual,10,1);
position = zeros(10,3);
%use a loop
for i=1:10
pop(i).pos = position(i,:);
end;
How to assign each row of a matrix to a field of a structured array without a loop?

Best Answer

One possible way to avoid for-loop:
position = zeros(10,3);
pop = table(position,cell(10,1),'VariableNames',{'pos','fit'});
pop = table2struct(pop);