mseq.m
资源名称:MIMO-OFDM.rar [点击查看]
上传用户:look542
上传日期:2009-06-04
资源大小:784k
文件大小:1k
源码类别:
传真(Fax)编程
开发平台:
Matlab
- % Program 5-3
- % mseq.m
- %
- % The generation function of M-sequence
- %
- % An example
- % stg = 3
- % taps = [ 1 , 3 ]
- % inidata = [ 1 , 1 , 1 ]
- % n = 2
- %
- % Programmed by M.Okita and H.Harada
- %
- function [mout] = mseq(stg, taps, inidata, n)
- % ****************************************************************
- % stg : Number of stages
- % taps : Position of register feedback
- % inidata : Initial sequence
- % n : Number of output sequence(It can be omitted)
- % mout : output M sequence
- % ****************************************************************
- if nargin < 4
- n = 1;
- end
- mout = zeros(n,2^stg-1);
- fpos = zeros(stg,1);
- fpos(taps) = 1;
- for ii=1:2^stg-1
- mout(1,ii) = inidata(stg); % storage of the output data
- num = mod(inidata*fpos,2); % calculation of the feedback data
- inidata(2:stg) = inidata(1:stg-1); % one shifts the register
- inidata(1) = num; % return feedback data
- end
- if n > 1
- for ii=2:n
- mout(ii,:) = shift(mout(ii-1,:),1,0);
- end
- end
- %******************************** end of file ********************************