在GF(2)的MATLAB中定义矩阵

时间:2014-03-02 21:30:20

标签: matrix matlab

我之前从未使用过MATLAB,但我必须做一个处理25(行)x 25(col)矩阵的操作。所以我不想手工做到这一点。所以我必须使用matlab。

我想在GF(2)的MATLAB中定义矩阵(2阶的Galois域是一个称为字段的数学结构,提供算术模2的正式定义。)

以下是我的5x5矩阵,我从命令null获取空格(MATRIX,'r')

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

以下是我的6x6矩阵,当我尝试命令null(MATRIX,'r')时,我得到空结果

1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 1 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 0 0 0 1 1 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
1 0 0 0 0 0 1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 
0 1 0 0 0 0 1 1 1 0 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0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1 1

任何人都可以告诉我是什么原因吗?

3 个答案:

答案 0 :(得分:1)

由于矩阵的所有元素都是这样写的,只需写A=[然后复制矩阵,然后放];。例如,如果矩阵是

1 2 3
4 5 6
7 8 9

然后你可以做

A=[1 2 3
   4 5 6
   7 8 9];

然后找到使用null(A)的空格。

答案 1 :(得分:0)

对于第二部分,你能在matlab中使用函数“null”吗? http://www.mathworks.com/help/matlab/ref/null.html

对于第一部分,也许这会有所帮助:Learning to build band matrices in MATLAB

你正在尝试制作带状矩阵,对角线上的带子也会增加5,然后减少5。为了制作这些,我认为你可以做到

[m,n] = size(A);
i = 1;
for j = 6:n
    A(i,j) = 1;
    i = i+1;
end

这将产生上对角线。要做到更低,只需做

j = 1;
for i = 6:n
    A(i,j) = 1;
    j = j+1;
end

答案 2 :(得分:0)

构造这种带状矩阵的更简单方法是

A = toeplitz([1 1 0 0 0 0 1 0(1,18)])

我的经验法则:每个for循环都无法有效地使用Matlab。