2013-07-02 246 views
-3

我想創建一個A =零(220,120)的矩陣。matlab中的矩陣

基本上我想這樣如果A =零(12,6)。

A = [ 1 0 0 0 0 0; 
     1 1 0 0 0 0; 
     1 1 1 0 0 0; 
    -1 0 0 0 0 0; 
    -1 -1 0 0 0 0; 
    -1 -1 -1 0 0 0; 
     0 0 0 1 0 0; 
     0 0 0 1 1 0; 
     0 0 0 1 1 1;  
     0 0 0 -1 0 0; 
     0 0 0 -1 -1 0; 
     0 0 0 -1 -1 -1 ] 

回答

1
m = 12; % is not actually used 
n = 6; 

Z = zeros(n/2); 
T = tril(ones(n/2)); 

A = [T Z; -T Z; Z T; Z -T]; % creates the matrix 

就讓n = 120,你應該得到的A你想要的。