Iam a beginner in matlab. I have an array of numbers. Say 5 (4,2,1,4,3) Which means the variable 1 can take a value from 0 to 1, variable 2 can take a value 1,2 Variable 3 can take 0 and 1, Variable 4 can take from 0 to 4, Variable 5 can take from 0 t0 3.
I tried using "combntns" in matlab but it is a specific one and not like my case where each variable is having defined set of numbers. I need all combinations. I tried using for loop
for a=i1:-1:0
for b=i2:-1:0
for c =i3:-1:0
for d=i4:-1:0
for e = i5:-1:0
com(j,1)=a;
com(j,2)=b;
com(j,3)=c;
com(j,4)=d;
com(j,5)=e;
j=j+1;
end
end
end
end
I dont want to use these many for loops. If my array size increases to 100 numbers, then it is a very big task to write 100 for loops. Can anyone suggest me with a code?