[讨论] 产生arrays

楼主: GSXSP (Gloria)   2017-03-21 06:41:56
我想产生
N = 4
a{1} = 1111111100000000
a{2} = 1111000011110000
a{3} = 1100110011001100
a{4} = 1010101010101010
N = 5
a{1} = 11111111111111110000000000000000
a{2} = 11111111000000001111111100000000
a{3} = 11110000111100001111000011110000
a{4} = 11001100110011001100110011001100
a{5} = 10101010101010101010101010101010
这样的arrays
目前我直接
for i=1:N
a{i} = zeros(1,2^N);
for j=1:2^N
if mod(floor((j*(2^i)-1)/2^N),2) == 0
a{i}(j) = 1;
end
end
end
end
有点慢, 不晓的有没有比较快的方法?

Links booklink

Contact Us: admin [ a t ] ucptt.com