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

📄 tutbchsq.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 4 页
字号:
function [ret,x0,str,ts,xts]=tutbchsq(t,x,u,flag);
%TUTBCHSQ	is the M-file description of the SIMULINK system named TUTBCHSQ.
%	TUTBCHSQ has a the following characteristics:
%		0 continuous states
%		17 discrete states
%		0 outputs
%		0 inputs
%		does not have direct feedthrough
%		5 sample times
%
%	The block-diagram can be displayed by typing: TUTBCHSQ.
%
%	SYS=TUTBCHSQ(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 TUTBCHSQ 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 TUTBCHSQ with a FLAG of zero:
%	[SIZES]=TUTBCHSQ([],[],[],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',[-8,81,591,234])
     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', '10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')


%     Subsystem  'Sampled read'.

new_system([sys,'/','Sampled read'])
set_param([sys,'/','Sampled read'],'Location',[355,528,737,675])

add_block('built-in/S-Function',[sys,'/','Sampled read/Message source'])
set_param([sys,'/','Sampled read/Message source'],...
		'BackGround',5,...
		'function name','trigwksp',...
		'parameters','var,thd,cyclFlag,ini',...
		'Mask Display','Triggered\nread',...
		'Mask Type','Read from workspace')
set_param([sys,'/','Sampled read/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).|Output before first trigger:')
set_param([sys,'/','Sampled read/Message source'],...
		'Mask Translate','var=@1;thd=@2;cyclFlag=@3;ini=@4;',...
		'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,'/','Sampled read/Message source'],...
		'Mask Entries','var\/.1\/cyc\/ini\/',...
		'position',[180,53,255,97])

add_block('built-in/Outport',[sys,'/','Sampled read/out_1'])
set_param([sys,'/','Sampled read/out_1'],...
		'position',[295,65,315,85])


%     Subsystem  ['Sampled read/Pulses deivide',13,'same sample time1'].

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

add_block('built-in/Outport',[sys,'/',['Sampled read/Pulses deivide',13,'same sample time1/Outport']])
set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1/Outport']],...
		'position',[160,35,180,55])

add_block('built-in/S-Function',[sys,'/',['Sampled read/Pulses deivide',13,'same sample time1/S-function1']])
set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1/S-function1']],...
		'function name','homopuls',...
		'parameters','samp_time, out_divid, offset',...
		'position',[40,31,105,59])
add_line([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1']],[110,45;155,45])
set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1']],...
		'Mask Display','Vector\nPulse',...
		'Mask Type','Pulse generator')
set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1']],...
		'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,'/',['Sampled read/Pulses deivide',13,'same sample time1']],...
		'Mask Translate','samp_time=@1;out_divid=@2;offset=@3;')
set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1']],...
		'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,'/',['Sampled read/Pulses deivide',13,'same sample time1']],...
		'Mask Entries','ts\/1\/off\/')


%     Finished composite block ['Sampled read/Pulses deivide',13,'same sample time1'].

set_param([sys,'/',['Sampled read/Pulses deivide',13,'same sample time1']],...
		'position',[50,56,110,94])
add_line([sys,'/','Sampled read'],[115,75;175,75])
add_line([sys,'/','Sampled read'],[260,75;290,75])
set_param([sys,'/','Sampled read'],...
		'Mask Display','Sampled\nread\nvariable',...
		'Mask Type','Read from variable')
set_param([sys,'/','Sampled read'],...
		'Mask Dialogue','Read from a workspace variable at given interval.|Variable (column_number=block_output_length):|Output symbol interval:|Cyclic read (1) or amend zero (0):|Initial output:')
set_param([sys,'/','Sampled read'],...
		'Mask Translate','var=@1;td=@2;ts=td(1);if (length(td)>=2),off=td(2);else off=0;end;cyc=@3;ini=@4;')
set_param([sys,'/','Sampled read'],...
		'Mask Help','This block reads from a workspace variable at a given sample time. The column number is the block output vector length. When the simulation reached the end of the variable row, the block will cyclically output from the first row of the the variable or output zero based on the cyclic read entree.')
set_param([sys,'/','Sampled read'],...
		'Mask Entries','randint(1000,1,2)\/1/5\/1\/0\/')


%     Finished composite block 'Sampled read'.

set_param([sys,'/','Sampled read'],...
		'hide name',0,...
		'position',[25,53,100,97])


%     Subsystem  ['Binary-sequential',13,'BCH encode1'].

new_system([sys,'/',['Binary-sequential',13,'BCH encode1']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1']],'Location',[248,302,892,459])

add_block('built-in/Outport',[sys,'/',['Binary-sequential',13,'BCH encode1/out_2']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/out_2']],...
		'Port','2',...
		'position',[535,45,555,65])


%     Subsystem  ['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down'].

new_system([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],'Location',[306,291,744,461])

add_block('built-in/Outport',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/out_1']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/out_1']],...
		'position',[390,60,410,80])

add_block('built-in/Outport',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/out_2']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/out_2']],...
		'Port','2',...
		'position',[355,80,375,100])

add_block('built-in/Mux',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/Mux']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/Mux']],...
		'inputs','[in_size 1 1]',...
		'position',[110,59,140,101])

add_block('built-in/Demux',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/Demux']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/Demux']],...
		'outputs','[out_size 1]',...
		'position',[290,62,330,98])

add_block('built-in/S-Function',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/S-function']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/S-function']],...
		'function name','regdown',...
		'parameters','ini_idx, idx_inc, thrshld, cycl_flag',...
		'position',[185,70,235,90])

add_block('built-in/Inport',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/in_1']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/in_1']],...
		'position',[15,55,35,75])

add_block('built-in/Inport',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/in_2']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/in_2']],...
		'Port','2',...
		'position',[40,70,60,90])

add_block('built-in/Inport',[sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/in_3']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down/in_3']],...
		'Port','3',...
		'position',[65,85,85,105])
add_line([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],[240,80;285,80])
add_line([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],[145,80;180,80])
add_line([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],[40,65;105,65])
add_line([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],[335,70;385,70])
add_line([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],[65,80;105,80])
add_line([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],[335,90;350,90])
add_line([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],[90,95;105,95])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],...
		'Mask Display','Triggered\nbuffer dn',...
		'Mask Type','Triggered buffer down.')
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],...
		'Mask Dialogue','Triggered buffer down.|Input signal vector size:|Initial index (integer vector):|Increament for each index (integer vector):|Trigger threshold:|When index exceed register size, 1 for cyclic ouput, 0 for zero output:')
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],...
		'Mask Translate','in_size=@1; ini_idx=@2; idx_inc=@3; thrshld=@4; cycl_flag=@5; out_size=length(ini_idx);')
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],...
		'Mask Help','The register inside this block take the signal vector at the 1st inport by the raising edge of the second inport. The fisrt outport outputs a signal vector at the raising edge of the third inport.')
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],...
		'Mask Entries','n\/0\/1\/.1\/0\/')


%     Finished composite block ['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down'].

set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Triggered',13,'buffer down']],...
		'BackGround',3,...
		'position',[445,28,505,62])

add_block('built-in/Outport',[sys,'/',['Binary-sequential',13,'BCH encode1/out_1']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/out_1']],...
		'position',[575,30,595,50])

add_block('built-in/Demux',[sys,'/',['Binary-sequential',13,'BCH encode1/Demux']])
set_param([sys,'/',['Binary-sequential',13,'BCH encode1/Demux']],...
		'outputs','2',...
		'position',[140,80,180,115])

⌨️ 快捷键说明

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