⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tstrssq.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 5 页
字号:
function [ret,x0,str,ts,xts]=tstrssq(t,x,u,flag);
%TSTRSSQ       is the M-file description of the SIMULINK system named TSTRSSQ.
%        The block-diagram can be displayed by typing: TSTRSSQ.
%
%        SYS=TSTRSSQ(T,X,U,FLAG) returns depending on FLAG certain
%      system values given time point, T, current state vector, X,
%    and input vector, U.
%   FLAG is used to indicate the type of output to be returned in SYS.
%
%    Setting FLAG=1 causes TSTRSSQ to return state derivatives, FLAG=2
%      discrete states, FLAG=3 system outputs and FLAG=4 next sample
%  time. For more information and other options see SFUNC.
%
%       Calling TSTRSSQ with a FLAG of zero:
%   [SIZES]=TSTRSSQ([],[],[],0),  returns a vector, SIZES, which
%   contains the sizes of the state vector and other parameters.
%           SIZES(1) number of states
%              SIZES(2) number of discrete states
%             SIZES(3) number of outputs
%             SIZES(4) number of inputs
%              SIZES(5) number of roots (currently unsupported)
%               SIZES(6) direct feedthrough flag
%               SIZES(7) number of sample times
%
%       For the definition of other parameters in SIZES, see SFUNC.
%    See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.

% Note: This M-file is only used for saving graphical information;
%       after the model is loaded into memory an internal model
%       representation is used.

% the system will take on the name of this mfile:
sys = mfilename;
new_system(sys)
simver(1.3)
if (0 == (nargin + nargout))
     set_param(sys,'Location',[62,53,963,404])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '999999')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '1')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')
set_param(sys,'Load callback','N_rs_demo=15;K_rs_demo=9;M_rs_demo=4;GWN=.05');

add_block('built-in/Note',[sys,'/','In this demo, you may sent the variable code word length N, message length K, and probability of noise..'])
set_param([sys,'/','In this demo, you may sent the variable code word length N, message length K, and probability of noise..'],...
             'position',[395,270,400,275])

add_block('built-in/S-Function',[sys,'/','Message source'])
set_param([sys,'/','Message source'],...
                'BackGround',5,...
              'function name','trigwksp',...
          'parameters','var,thd,cyclFlag',...
             'Mask Display','Triggered\nread',...
            'Mask Type','Read from workspace')
set_param([sys,'/','Message source'],...
              'Mask Dialogue','The raising edge of input pulse trigger the block output the next row from the workspace variable.|Read the variable:|Threshold for the input pulse:|Cyclic read variable (1) or amend zeros (0).')
set_param([sys,'/','Message source'],...
            'Mask Translate','var=@1;thd=@2;cyclFlag=@3;',...
               'Mask Help','This block reads the data from a workspace variable. The output is refreshed at the raising edge of the input pulse.')
set_param([sys,'/','Message source'],...
             'Mask Entries','randint(K_rs_demo*M_rs_demo,1)\/.1\/1\/',...
            'position',[200,100,265,140])


%     Subsystem  'Delay'.

new_system([sys,'/','Delay'])
set_param([sys,'/','Delay'],'Location',[19,610,374,740])

add_block('built-in/Demux',[sys,'/','Delay/Demux'])
set_param([sys,'/','Delay/Demux'],...
             'outputs','[len_rg, 1]',...
             'position',[260,55,300,90])

add_block('built-in/S-Function',[sys,'/','Delay/S-function'])
set_param([sys,'/','Delay/S-function'],...
              'function name','regshift',...
          'parameters','shft_out, thrhld',...
             'position',[150,65,200,85])

add_block('built-in/Mux',[sys,'/','Delay/Mux'])
set_param([sys,'/','Delay/Mux'],...
           'inputs','2',...
                'position',[80,56,115,89])

add_block('built-in/Outport',[sys,'/','Delay/out_1'])
set_param([sys,'/','Delay/out_1'],...
            'position',[330,55,350,75])

add_block('built-in/Outport',[sys,'/','Delay/out_2'])
set_param([sys,'/','Delay/out_2'],...
           'Port','2',...
          'position',[330,70,350,90])

add_block('built-in/Inport',[sys,'/','Delay/in_1'])
set_param([sys,'/','Delay/in_1'],...
              'position',[30,55,50,75])

add_block('built-in/Inport',[sys,'/','Delay/in_2'])
set_param([sys,'/','Delay/in_2'],...
                'Port','2',...
          'position',[30,70,50,90])
add_line([sys,'/','Delay'],[120,75;145,75])
add_line([sys,'/','Delay'],[205,75;255,75])
add_line([sys,'/','Delay'],[305,65;325,65])
add_line([sys,'/','Delay'],[305,80;325,80])
add_line([sys,'/','Delay'],[55,65;75,65])
add_line([sys,'/','Delay'],[55,80;75,80])
set_param([sys,'/','Delay'],...
          'Mask Display','Register\nshift',...
            'Mask Type','Register-shift')
set_param([sys,'/','Delay'],...
            'Mask Dialogue','Store and shift the input from 1st port by raising edge of the pulse from second port.|Vector specify ouput delay length(non-negative integer):|Threshold for the pulse signal from the 2nd port:')
set_param([sys,'/','Delay'],...
             'Mask Translate','shft_out=@1; thrhld=@2; len_rg=length(@1);')
set_param([sys,'/','Delay'],...
           'Mask Help','This block store the 1st inport signal at the raising edge of 2nd inport pulse. The 1st outport outputs a vector with its size same as the the size of the 1st entree of this block. The maximum delay is the register size of this block. The second outport output a positive pulse at the begining of entire register refreshment.')
set_param([sys,'/','Delay'],...
             'Mask Entries','K_rs_demo*M_rs_demo*2\/.1\/')


%     Finished composite block 'Delay'.

set_param([sys,'/','Delay'],...
             'BackGround',5,...
              'position',[310,35,365,75])

add_block('built-in/Demux',[sys,'/','Demux'])
set_param([sys,'/','Demux'],...
         'outputs','3',...
               'position',[125,57,165,93])


%     Subsystem  ['Pulses deivide',13,'same sample time'].

new_system([sys,'/',['Pulses deivide',13,'same sample time']])
set_param([sys,'/',['Pulses deivide',13,'same sample time']],'Location',[55,192,283,286])

add_block('built-in/S-Function',[sys,'/',['Pulses deivide',13,'same sample time/S-function1']])
set_param([sys,'/',['Pulses deivide',13,'same sample time/S-function1']],...
         'function name','homopuls',...
          'parameters','samp_time, out_divid, offset',...
         'position',[40,31,105,59])

add_block('built-in/Outport',[sys,'/',['Pulses deivide',13,'same sample time/Outport']])
set_param([sys,'/',['Pulses deivide',13,'same sample time/Outport']],...
              'position',[160,35,180,55])
add_line([sys,'/',['Pulses deivide',13,'same sample time']],[110,45;155,45])
set_param([sys,'/',['Pulses deivide',13,'same sample time']],...
         'Mask Display','Vector\nPulse',...
              'Mask Type','Pulse generator')
set_param([sys,'/',['Pulses deivide',13,'same sample time']],...
          'Mask Dialogue','Vector pulses with sample rate of each pulse as Sample_time ./Divider. |Sample time (scalar, sec):|Divider (integer vector):|Offset (have same dimension as Divider):')
set_param([sys,'/',['Pulses deivide',13,'same sample time']],...
                'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Pulses deivide',13,'same sample time']],...
                'Mask Help','This block generator a vector pulses. The output length is the same as the vector defined in "Divider". The ith element of the output has the sample time Sample_time/Divider(i). All elements in "Divider" must be integers.')
set_param([sys,'/',['Pulses deivide',13,'same sample time']],...
            'Mask Entries','1\/[K_rs_demo*M_rs_demo, N_rs_demo, K_rs_demo]\/[0,0,0]\/')


%     Finished composite block ['Pulses deivide',13,'same sample time'].

set_param([sys,'/',['Pulses deivide',13,'same sample time']],...
             'position',[30,56,90,94])

add_block('built-in/Note',[sys,'/','Recovered message'])
set_param([sys,'/','Recovered message'],...
            'ForeGround',2,...
              'position',[640,90,645,95])

add_block('built-in/Note',[sys,'/','Delayed message source'])
set_param([sys,'/','Delayed message source'],...
                'ForeGround',5,...
              'position',[630,65,635,70])

add_block('built-in/Mux',[sys,'/','Mux1'])
set_param([sys,'/','Mux1'],...
             'inputs','3',...
                'position',[775,163,810,217])

add_block('built-in/Note',[sys,'/','Error detected in decoding'])
set_param([sys,'/','Error detected in decoding'],...
              'ForeGround',2,...
              'position',[675,145,680,150])

add_block('built-in/S-Function',[sys,'/',['White Guassian',13,'noise source']])
set_param([sys,'/',['White Guassian',13,'noise source']],...
                'ForeGround',3,...
              'function name','trigwksp',...
          'parameters','var,thd,cyclFlag',...
             'Mask Display','Triggered\nread',...
            'Mask Type','Read from workspace')
set_param([sys,'/',['White Guassian',13,'noise source']],...
          'Mask Dialogue','The raising edge of input pulse trigger the block output the next row from the workspace variable.|Read the variable:|Threshold for the input pulse:|Cyclic read variable (1) or amend zeros (0).')
set_param([sys,'/',['White Guassian',13,'noise source']],...
                'Mask Translate','var=@1;thd=@2;cyclFlag=@3;',...
               'Mask Help','This block reads the data from a workspace variable. The output is refreshed at the raising edge of the input pulse.')
set_param([sys,'/',['White Guassian',13,'noise source']],...
         'Mask Entries','rand(1000,1)<GWN\/.1\/1\/',...
          'position',[245,190,310,230])

add_block('built-in/Note',[sys,'/','Grouping signal'])

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -