MATLAB: How to create a variable from cell array contents

cell arrayMATLAB

I have a cell Array vector as attached (length may vary). It contains variable names.
mycell =
5×1 cell array
{'x' }
{'y' }
{'var1'}
{'var2'}
{'var3'}
How to create a new variable as follows?
out = [x;y;var1;var2;var3];

Best Answer

You can use struct:
for idx_cell = 1:size(mycell,1) out.(mycell{idx_cell})={}; end