Matlab可不可以实现生产一个01矩阵,且保证每行只能有一个1

Matlab可不可以实现生产一个01矩阵,且保证每行只能有一个1

同学你好,供参考

m=10;
n=6;
a = full(sparse(1:m,randi([1,n],1,m),1,m,n))

结果(因为是随机的,仅供参考):

a =

     1     0     0     0     0     0
     1     0     0     0     0     0
     0     0     0     0     1     0
     0     0     0     0     1     0
     0     1     0     0     0     0
     0     0     0     0     0     1
     1     0     0     0     0     0
     0     0     1     0     0     0
     0     0     1     0     0     0
     0     0     0     0     1     0

举例:
out = randerr(11,8,1)%11行8列

单位矩阵?