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

📄 tutconmd.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [ret,x0,str,ts,xts]=tutconmd(t,x,u,flag);
%TUTCONMD	is the M-file description of the SIMULINK system named TUTCONMD.
%	The block-diagram can be displayed by typing: TUTCONMD.
%
%	SYS=TUTCONMD(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 TUTCONMD 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 TUTCONMD with a FLAG of zero:
%	[SIZES]=TUTCONMD([],[],[],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',[382,42,908,304])
     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/Logical Operator',[sys,'/',['Logical',13,'Operator1']])
set_param([sys,'/',['Logical',13,'Operator1']],...
		'ForeGround',4,...
		'hide name',0,...
		'Operator','XOR',...
		'position',[355,13,385,62])

add_block('built-in/Outport',[sys,'/','Outport'])
set_param([sys,'/','Outport'],...
		'position',[445,30,465,50])

add_block('built-in/Logical Operator',[sys,'/',['Logical',13,'Operator2']])
set_param([sys,'/',['Logical',13,'Operator2']],...
		'ForeGround',4,...
		'hide name',0,...
		'Operator','XOR',...
		'Number of Input Ports','3',...
		'position',[355,95,385,145])

add_block('built-in/Outport',[sys,'/','Outport1'])
set_param([sys,'/','Outport1'],...
		'Port','2',...
		'position',[450,110,470,130])

add_block('built-in/Logical Operator',[sys,'/',['Logical',13,'Operator3']])
set_param([sys,'/',['Logical',13,'Operator3']],...
		'ForeGround',4,...
		'hide name',0,...
		'Operator','XOR',...
		'position',[355,178,385,227])

add_block('built-in/Outport',[sys,'/','Outport2'])
set_param([sys,'/','Outport2'],...
		'Port','3',...
		'position',[455,195,475,215])

add_block('built-in/Memory',[sys,'/','Memory'])
set_param([sys,'/','Memory'],...
		'ForeGround',2,...
		'hide name',0,...
		'position',[140,65,180,95])

add_block('built-in/Memory',[sys,'/','Memory1'])
set_param([sys,'/','Memory1'],...
		'ForeGround',2,...
		'hide name',0,...
		'position',[240,65,280,95])

add_block('built-in/Inport',[sys,'/','Inport'])
set_param([sys,'/','Inport'],...
		'position',[40,70,60,90])

add_block('built-in/Memory',[sys,'/','Memory2'])
set_param([sys,'/','Memory2'],...
		'ForeGround',2,...
		'hide name',0,...
		'position',[140,120,180,150])

add_block('built-in/Inport',[sys,'/','Inport1'])
set_param([sys,'/','Inport1'],...
		'ForeGround',3,...
		'Port','2',...
		'position',[40,125,60,145])
add_line(sys,[390,40;440,40])
add_line(sys,[390,120;445,120])
add_line(sys,[390,205;450,205])
add_line(sys,[185,80;235,80])
add_line(sys,[285,80;310,80;310,50;350,50])
add_line(sys,[310,80;310,105;350,105])
add_line(sys,[65,80;135,80])
add_line(sys,[65,135;135,135])
add_line(sys,[210,80;210,120;350,120])
add_line(sys,[210,120;210,190;350,190])
add_line(sys,[185,135;350,135])
add_line(sys,[105,135;105,215;350,215])
add_line(sys,[105,80;105,25;350,25])

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 + -