MATLAB: Convert a vector into a structure array field

structure arrayvector

x= [2; 8; 6; 3; 7; 8];
for i=1:numel(x)
s(i).x=x(i);
end
Do the same, but without cycle.

Best Answer

If struct s does not exist yet, you could use:
s = struct('x', num2cell(x));