MATLAB: How to dynamically create a struct

cellcreatedynamicfieldstruct

I want to create a struct with the number of fields decided based on some user input. What's a good way of doing this? Or should I be using a cell or matrix instead?
Thanks

Best Answer

a = struct ;
for i = 1:10
a(i).x = i ;
a(i).y = i+1 ;
end
It depends on how your structure is.