clc
clear
A=zeros(1,4);
for i=1:2^4-1
a=dec2bin(i);
n=numel(a);
m=4-n;
k=[];
for j=1:n
k=[k,str2num(a(j))];
end
temp=[zeros(1,m),k];
A=[A;temp];
end
A
结果
A =
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
挺笨的方法,仅供参考.
clc
clear
A=zeros(1,4);
for i=1:2^4-1
a=dec2bin(i);
n=numel(a);
m=4-n;
k=[];
for j=1:n
k=[k,str2num(a(j))];
end
temp=[zeros(1,m),k];
A=[A;temp];
end
A
结果
A =
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
1111
挺笨的方法,仅供参考.