请解释matlab中程序每一行的意思,谢谢函数m_sequence.m :function[mseq]=m_sequence(fbconnection);n=length(fbconnection);N=2^n-1;register=[zeros(1,n-1) 1]; mseq(1)=register(n); for i=2:Nnewregister(1)=mod(sum(fbconnection.*
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/15 05:59:02
请解释matlab中程序每一行的意思,谢谢函数m_sequence.m :function[mseq]=m_sequence(fbconnection);n=length(fbconnection);N=2^n-1;register=[zeros(1,n-1) 1]; mseq(1)=register(n); for i=2:Nnewregister(1)=mod(sum(fbconnection.*
请解释matlab中程序每一行的意思,谢谢
函数m_sequence.m :
function[mseq]=m_sequence(fbconnection);
n=length(fbconnection);
N=2^n-1;
register=[zeros(1,n-1) 1];
mseq(1)=register(n);
for i=2:N
newregister(1)=mod(sum(fbconnection.*register),2);
for j=2:n
newregister(j)=register(j-1);
end;
register=newregister;
mseq(i)=register(n);
end
请解释matlab中程序每一行的意思,谢谢函数m_sequence.m :function[mseq]=m_sequence(fbconnection);n=length(fbconnection);N=2^n-1;register=[zeros(1,n-1) 1]; mseq(1)=register(n); for i=2:Nnewregister(1)=mod(sum(fbconnection.*
function[mseq]=m_sequence(fbconnection);%%函数声明,函数名字m_sequence,函数输入变量fbconnection,函数输出mseq
n=length(fbconnection);%%得到fbconnection的长度
N=2^n-1;%%得到循环次数
register=[zeros(1,n-1) 1];%%建立大小为1*n的矩阵,前n-1个元素都为0,第n个元素为1
mseq(1)=register(n); %%让输出的第一个元素为1
for i=2:N%%i从2开始循环,一直去到N
newregister(1)=mod(sum(fbconnection.*register),2); %%让fbconnection和register中对应元素相乘,并求和,然后除以2得余数赋给newregister的第一个元素
for j=2:n
newregister(j)=register(j-1);%%把register的前n-1个元素赋给newregister的第2-n个元素,也就是全0
end;
register=newregister;%%把newregister的值赋给register
mseq(i)=register(n);%%把register的第n个元素的值赋给mseq的第i个元素
end