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

📄 comcdlin.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 4 页
字号:
function [ret,x0,str,ts,xts]=comcdlin(t,x,u,flag);
%COMCDLIN	is the M-file description of the SIMULINK system named COMCDLIN.
%	The block-diagram can be displayed by typing: COMCDLIN.
%
%	SYS=COMCDLIN(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 COMCDLIN 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 COMCDLIN with a FLAG of zero:
%	[SIZES]=COMCDLIN([],[],[],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',[356,448,774,675])
     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  ['Sequence lin-blk',13,'co//dec demo'].

new_system([sys,'/',['Sequence lin-blk',13,'co//dec demo']])
set_param([sys,'/',['Sequence lin-blk',13,'co//dec demo']],'Location',[175,552,335,697])
set_param([sys,'/',['Sequence lin-blk',13,'co//dec demo']],...
		'Mask Display','Lin-blk\nco/dec\ndemo',...
		'Mask Dialogue','eval(''G_lin=[1 0 1 1;1 1 1 0;0 1 1 1;eye(4)];trt=0;tstlinsq'')')


%     Finished composite block ['Sequence lin-blk',13,'co//dec demo'].

set_param([sys,'/',['Sequence lin-blk',13,'co//dec demo']],...
		'BackGround',7,...
		'hide name',0,...
		'position',[295,133,375,177])


%     Subsystem  ['Vector lin-blk',13,'co//dec demo'].

new_system([sys,'/',['Vector lin-blk',13,'co//dec demo']])
set_param([sys,'/',['Vector lin-blk',13,'co//dec demo']],'Location',[175,552,335,697])
set_param([sys,'/',['Vector lin-blk',13,'co//dec demo']],...
		'Mask Display','Lin-blk\nco/dec\ndemo',...
		'Mask Dialogue','eval(''tstlinco'')')


%     Finished composite block ['Vector lin-blk',13,'co//dec demo'].

set_param([sys,'/',['Vector lin-blk',13,'co//dec demo']],...
		'BackGround',7,...
		'hide name',0,...
		'position',[295,53,375,97])


%     Subsystem  ['Binary vector',13,'lin-blk encode'].

new_system([sys,'/',['Binary vector',13,'lin-blk encode']])
set_param([sys,'/',['Binary vector',13,'lin-blk encode']],'Location',[235,592,599,711])

add_block('built-in/Inport',[sys,'/',['Binary vector',13,'lin-blk encode/in_1']])
set_param([sys,'/',['Binary vector',13,'lin-blk encode/in_1']],...
		'position',[30,35,50,55])

add_block('built-in/State-Space',[sys,'/',['Binary vector',13,'lin-blk encode/Matrix',13,'Gain']])
set_param([sys,'/',['Binary vector',13,'lin-blk encode/Matrix',13,'Gain']],...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','K',...
		'Mask Type','Matrix Gain',...
		'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['Binary vector',13,'lin-blk encode/Matrix',13,'Gain']],...
		'Mask Translate','K = @1;',...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
		'Mask Entries','G\/')
set_param([sys,'/',['Binary vector',13,'lin-blk encode/Matrix',13,'Gain']],...
		'position',[110,31,135,59])

add_block('built-in/S-Function',[sys,'/',['Binary vector',13,'lin-blk encode/Modulus',13,'operation']])
set_param([sys,'/',['Binary vector',13,'lin-blk encode/Modulus',13,'operation']],...
		'function name','arymodu',...
		'parameters','md',...
		'Mask Display','Modulo',...
		'Mask Type','Modulo')
set_param([sys,'/',['Binary vector',13,'lin-blk encode/Modulus',13,'operation']],...
		'Mask Dialogue','Modulus operation:|Modulus base:',...
		'Mask Translate','md = @1;')
set_param([sys,'/',['Binary vector',13,'lin-blk encode/Modulus',13,'operation']],...
		'Mask Help','This block output modulus operation of the input signal with module base as specified in block entry. The length of the output vector is the same as the input vector.')
set_param([sys,'/',['Binary vector',13,'lin-blk encode/Modulus',13,'operation']],...
		'Mask Entries','2\/',...
		'position',[180,26,240,64])

add_block('built-in/Outport',[sys,'/',['Binary vector',13,'lin-blk encode/out_1']])
set_param([sys,'/',['Binary vector',13,'lin-blk encode/out_1']],...
		'position',[290,35,310,55])
add_line([sys,'/',['Binary vector',13,'lin-blk encode']],[55,45;105,45])
add_line([sys,'/',['Binary vector',13,'lin-blk encode']],[140,45;175,45])
add_line([sys,'/',['Binary vector',13,'lin-blk encode']],[245,45;285,45])
set_param([sys,'/',['Binary vector',13,'lin-blk encode']],...
		'Mask Display','plot(0,0,100,100,x,y);Linear en',...
		'Mask Type','Vector I/O linear block encode')
set_param([sys,'/',['Binary vector',13,'lin-blk encode']],...
		'Mask Dialogue','Linear block encode with input message\nvector length K and output codeword vector length N.|Generator matrix (binary K-by-N matrix):')
set_param([sys,'/',['Binary vector',13,'lin-blk encode']],...
		'Mask Translate','G=@1'';[x,y]=codeicon(1);')
set_param([sys,'/',['Binary vector',13,'lin-blk encode']],...
		'Mask Help','Linear block encode with input message vector length K and output codeword vector length N. The generator matrix is a K-by-N matrix. Linear block code is a generic code.')
set_param([sys,'/',['Binary vector',13,'lin-blk encode']],...
		'Mask Entries','[[1 1 0; 0 1 1; 1 1 1; 1 0 1] eye(4)]\/')


%     Finished composite block ['Binary vector',13,'lin-blk encode'].

set_param([sys,'/',['Binary vector',13,'lin-blk encode']],...
		'position',[35,53,115,97])

add_block('built-in/Note',[sys,'/','Linear Block Coding//Decoding Library'])
set_param([sys,'/','Linear Block Coding//Decoding Library'],...
		'ForeGround',2,...
		'Font Weight','bold',...
		'Font Size',12,...
		'position',[200,10,205,15])


%     Subsystem  ['Binary vector',13,'lin-blk decode'].

new_system([sys,'/',['Binary vector',13,'lin-blk decode']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode']],'Location',[267,160,850,320])

add_block('built-in/Inport',[sys,'/',['Binary vector',13,'lin-blk decode/in_1']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode/in_1']],...
		'position',[30,35,50,55])

add_block('built-in/State-Space',[sys,'/',['Binary vector',13,'lin-blk decode/Matrix',13,'Gain']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Matrix',13,'Gain']],...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','K',...
		'Mask Type','Matrix Gain',...
		'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Matrix',13,'Gain']],...
		'Mask Translate','K = @1;',...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
		'Mask Entries','H\/')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Matrix',13,'Gain']],...
		'position',[100,31,125,59])

add_block('built-in/S-Function',[sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation']],...
		'function name','arymodu',...
		'parameters','md',...
		'Mask Display','Modulo',...
		'Mask Type','Modulo')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation']],...
		'Mask Dialogue','Modulus operation:|Modulus base:',...
		'Mask Translate','md = @1;')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation']],...
		'Mask Help','This block output modulus operation of the input signal with module base as specified in block entry. The length of the output vector is the same as the input vector.')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation']],...
		'Mask Entries','2\/',...
		'position',[140,26,200,64])

add_block('built-in/Combinatorial Logic',[sys,'/',['Binary vector',13,'lin-blk decode/Combinatorial',13,'Logic']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Combinatorial',13,'Logic']],...
		'Truth Table','trt',...
		'position',[225,33,255,57])

add_block('built-in/Sum',[sys,'/',['Binary vector',13,'lin-blk decode/Sum']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Sum']],...
		'position',[305,90,325,110])

add_block('built-in/S-Function',[sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation1']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation1']],...
		'function name','arymodu',...
		'parameters','md',...
		'Mask Display','Modulo',...
		'Mask Type','Modulo')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation1']],...
		'Mask Dialogue','Modulus operation:|Modulus base:',...
		'Mask Translate','md = @1;')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation1']],...
		'Mask Help','This block output modulus operation of the input signal with module base as specified in block entry. The length of the output vector is the same as the input vector.')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Modulus',13,'operation1']],...
		'Mask Entries','2\/',...
		'position',[340,81,400,119])

add_block('built-in/State-Space',[sys,'/',['Binary vector',13,'lin-blk decode/Matrix',13,'Gain1']])
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Matrix',13,'Gain1']],...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','K',...
		'Mask Type','Matrix Gain',...
		'Mask Dialogue','Matrix Gain.|Gain matrix:')
set_param([sys,'/',['Binary vector',13,'lin-blk decode/Matrix',13,'Gain1']],...
		'Mask Translate','K = @1;',...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector (y=Au).',...
		'Mask Entries','G\/')

⌨️ 快捷键说明

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