In the following code I get matrix 'a' with repeated columns. How to generate it without repetition?
2 次查看(过去 30 天)
显示 更早的评论
if true
k=3;
n=5;
m=(2*k)-2;
n1=k-1;
N=(factorial(m))/(factorial(n1)*factorial(n1));
o = ones(k-1,1) ;
z = zeros(k-1,1) ;
a1 = [o ; z];
n2=1;
for i=1:N
a(:,n2)= randsample([o ; z],m)
n2=n2+1;
end
end
0 个评论
采纳的回答
KSSV
2018-1-5
k=3;
n=5;
m=(2*k)-2;
n1=k-1;
N=(factorial(m))/(factorial(n1)*factorial(n1));
o = ones(k-1,1) ;
z = zeros(k-1,1) ;
a1 = [o ; z];
v = a1' ;
C = unique(perms(v),'rows') ;
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!