MATLAB: Storing vectors in a cluster

clusteringset

for i=2:10
a=...
end
I want to store matrixes as an element of a set for every cycle. I know they can be stored in a vector but in my main code loop may returns different number of elements over time.
example:
a=[2], a=[29 3], a=[3 2]
and set should be:
cluster={2, 29 3, 3 2}

Best Answer

a1=[2]; a2=[29 3]; a3=[3 2];
I will change them to cell array first for indexing, it is always my preference.
a(1)=num2cell(a1);
a(2)=num2cell(a2);
a(3)=num2cell(a3);
How to know the number of variable?
numVar = length(a); %or

numVar = numel(a); %or
numVar = size(a,2);
display your variable
a{:}