MATLAB: How to display Numbers of stacking sequence using permutations an combinations. in this case i have 6840 permutations and 1140 combinations. perms(a) command returning error

algebraarraycombinationsMATLABmatrixOptimization Toolboxpermutations

a=[45 45 45 45 45 45 0 0 0 0 0 0 0 0 -45 -45 -45 -45 -45 -45];
% No. of angle =20;
% No. of sub angle =3 Means (45 0 -45)
% 6840 permutations
% 1140 combinations
perms(a);
command is returning error

Best Answer

perms is only meaningful when you have distinct elements. When they are not distinct, as you have, the result will be huge, and as you have found, of course it will fail.
However, nothing stops you from writing code that will compute what you wish. You have only 3 distinct elements, so all that matters is knowing how many repetitions of each element there are in the global set.
As far as the claim that there are 6840 permutations of these 20 numbers, that is simply wrong.
You have 20 holes in which to place the number 0. There are 8 zeros to place, so there are
nchoosek(20,8)
ans =
125970
125970 places to put a zero. Of the remaining holes that are unfilled, they must contain either 45 or a -45.
nchoosek(12,6)
ans =
924
There are 924 such arrangements. Therefore, the unique set of permutations of the vector you wish to form will number
nchoosek(20,8)*nchoosek(12,6)
ans =
116396280
So roughly 116 million DISTINCT permutations of those elements.
That array of distinct permutations will require
nchoosek(20,8)*nchoosek(12,6)*20*8
ans =
1.8623e+10
roughly 18 gigabytes of RAM to store, as double precision numbers. If you need something else, and have not described your problem well, then you need to add a comment that explains your problem more clearly. Please do not keep asking the same question though, without bothering to clarify what you want.