Try the following:
Code:
an = 9;
bn = 4;
%build map with "double" key and "array" value
myMap = containers.Map(0,[0 0]);
myMap.remove(0);
for a = 1:an
for b = 1:bn
x = a*b;
if any(cell2mat(myMap.keys())== x) == 0;
myMap(x) = [a,b];
else
myMap(x) = [myMap(x);[a b]];
end
end
end
for i = cell2mat(myMap.keys())
eval(sprintf('variable_%i = myMap(i)',i))
end Im not sure if this is exactly what you are looking for, but I would be inclined to make use of the containers.Map class to keep the code as tidy as possible. I dont use it much, but it seems like the right application for it here.
Regards Elbarto