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

📄 compage3.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [ret,x0,str,ts,xts]=compage3(t,x,u,flag);
%COMPAGE3	is the M-file description of the SIMULINK system named COMPAGE3.
%	The block-diagram can be displayed by typing: COMPAGE3.
%
%	SYS=COMPAGE3(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 COMPAGE3 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 COMPAGE3 with a FLAG of zero:
%	[SIZES]=COMPAGE3([],[],[],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',[127,73,885,491])
     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',   '')

add_block('built-in/Note',[sys,'/','Use the redundancy bits//words to detect//correct errors caused by transformation'])
set_param([sys,'/','Use the redundancy bits//words to detect//correct errors caused by transformation'],...
		'position',[440,60,445,65])

add_block('built-in/Note',[sys,'/','Add redundancy bits//words in the transfer side.'])
set_param([sys,'/','Add redundancy bits//words in the transfer side.'],...
		'position',[345,30,350,35])

add_block('built-in/Note',[sys,'/','Error control Code//Decode:'])
set_param([sys,'/','Error control Code//Decode:'],...
		'Font Weight','bold',...
		'position',[105,30,110,35])


%     Subsystem  ['DPCM data',13,'training3'].

new_system([sys,'/',['DPCM data',13,'training3']])
set_param([sys,'/',['DPCM data',13,'training3']],'Location',[111,168,452,354])
set_param([sys,'/',['DPCM data',13,'training3']],...
		'Mask Display','BCH code\nexample',...
		'Mask Dialogue','eval(''tutbchcd;rk45(''''tutbchcd'''',30);'')')


%     Finished composite block ['DPCM data',13,'training3'].

set_param([sys,'/',['DPCM data',13,'training3']],...
		'BackGround',7,...
		'hide name',0,...
		'position',[610,103,685,151])

add_block('built-in/Note',[sys,'/','BCH code//decode example SIMULINK block diagram.'])
set_param([sys,'/','BCH code//decode example SIMULINK block diagram.'],...
		'ForeGround',4,...
		'position',[360,100,365,105])

add_block('built-in/Note',[sys,'/','This example shows the symbols before and after the translation.'])
set_param([sys,'/','This example shows the symbols before and after the translation.'],...
		'ForeGround',4,...
		'position',[390,125,395,130])


%     Subsystem  'transfer function'.

new_system([sys,'/','transfer function'])
set_param([sys,'/','transfer function'],'Location',[436,197,856,343])
set_param([sys,'/','transfer function'],...
		'Mask Display','Generating\ntran_func',...
		'Mask Dialogue','eval(''fig_10_9; tf = sim2gen(''''fig_10_9''''),[tmp,tmp2]=simviter(tf);N_con_demo=tmp(1);K_con_demo=tmp(2);'')')


%     Finished composite block 'transfer function'.

set_param([sys,'/','transfer function'],...
		'BackGround',7,...
		'hide name',0,...
		'position',[336,205,421,247])

add_block('built-in/Note',[sys,'/','Convolution code: constructed with shift registers and Modulo-2 sum (XOR) blocks. '])
set_param([sys,'/','Convolution code: constructed with shift registers and Modulo-2 sum (XOR) blocks. '],...
		'ForeGround',3,...
		'position',[446,170,451,175])

add_block('built-in/Note',[sys,'/','A SIMULINK demo for convolution coding with trellis display.'])
set_param([sys,'/','A SIMULINK demo for convolution coding with trellis display.'],...
		'ForeGround',6,...
		'position',[381,260,386,265])


%     Subsystem  ['Vector Convolution',13,'Co//Dec demo'].

new_system([sys,'/',['Vector Convolution',13,'Co//Dec demo']])
set_param([sys,'/',['Vector Convolution',13,'Co//Dec demo']],'Location',[175,552,335,697])
set_param([sys,'/',['Vector Convolution',13,'Co//Dec demo']],...
		'Mask Display','Convol\nCo/Dec',...
		'Mask Dialogue','eval(''tstconcd'')')


%     Finished composite block ['Vector Convolution',13,'Co//Dec demo'].

set_param([sys,'/',['Vector Convolution',13,'Co//Dec demo']],...
		'BackGround',7,...
		'hide name',0,...
		'position',[336,290,420,336])

drawnow

% Return any arguments.
if (nargin | nargout)
	% Must use feval here to access system in memory
	if (nargin > 3)
		if (flag == 0)
			eval(['[ret,x0,str,ts,xts]=',sys,'(t,x,u,flag);'])
		else
			eval(['ret =', sys,'(t,x,u,flag);'])
		end
	else
		[ret,x0,str,ts,xts] = feval(sys);
	end
else
	drawnow % Flash up the model and execute load callback
end

⌨️ 快捷键说明

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