Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想将超立方体在维度 n 中创建的所有向量存储在矩阵中,也就是说,对于维度 n=3,例如:
matrix = [[0 0 0], [0 0 1], [0 1 0], [0 1 1], [1 0 0], [1 0 1], [1 1 0], [1 1 1]]
在 scilab 有什么好的方法吗?
谢谢 !
也许这样(这就像在二进制中从 0 计数到 2^n-1)
n=3; mat = zeros(2^n,n); for i = 1:2^n mat(i,:) = bitget(i-1,1:n); end --> mat mat = 0. 0. 0. 1. 0. 0. 0. 1. 0. 1. 1. 0. 0. 0. 1. 1. 0. 1. 0. 1. 1. 1. 1. 1.