a = {'ball' , 'cake' , 'ice'};
b = {'home'};
c = {'car','moto'};
d = {'money'};
e = cell(4,0);
e(1,1:numel(a)) = a;
e(2,1:numel(b)) = b;
e(3,1:numel(c)) = c;
e(4,1:numel(d)) = d
"I would like to know if it can be done in a more general way..."
That will not be easy, because you split the data up into lots of separate variables. An efficient more general approach requires them to be kept together.