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

📄 lab05.m

📁 xnsy算法的matlab实现
💻 M
字号:
function [ret,x0,str,ts,xts]=lab05(t,x,u,flag);
%LAB05	is the M-file description of the SIMULINK system named LAB05.
%	The block-diagram can be displayed by typing: LAB05.
%
%	SYS=LAB05(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 LAB05 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 LAB05 with a FLAG of zero:
%	[SIZES]=LAB05([],[],[],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',[12,121,141,507])
     open_system(sys)
end;
set_param(sys,'algorithm',     'RK-45')
set_param(sys,'Start time',    '0.0')
set_param(sys,'Stop time',     '10')
set_param(sys,'Min step size', '0.0001')
set_param(sys,'Max step size', '0.01')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')

add_block('built-in/Note',[sys,'/','线性离散环节'])
set_param([sys,'/','线性离散环节'],...
		'ForeGround',4,...
		'Font Size',14,...
		'position',[70,10,75,15])

add_block('built-in/Unit Delay',[sys,'/','延迟器'])
set_param([sys,'/','延迟器'],...
		'position',[50,41,80,69])

add_block('built-in/Discrete Transfer Fcn',[sys,'/','z传函2'])
set_param([sys,'/','z传函2'],...
		'Denominator','[1 0.5]',...
		'position',[45,247,90,283])

add_block('built-in/Filter',[sys,'/','z传函1'])
set_param([sys,'/','z传函1'],...
		'Denominator','[1 2]',...
		'position',[45,176,90,214])

add_block('built-in/Discrete Transfer Fcn',[sys,'/',['零阶采样',13,'保持器']])
set_param([sys,'/',['零阶采样',13,'保持器']],...
		'Numerator','1',...
		'Denominator','1',...
		'Sample time','Ts',...
		'Mask Display','plot(0,0,100,100,[90,70,70,50,50,30,30,10],[30,30,50,50,80,80,20,20])',...
		'Mask Type','Zero Order Hold')
set_param([sys,'/',['零阶采样',13,'保持器']],...
		'Mask Dialogue','Zero Order Hold|Sample Time:',...
		'Mask Translate','Ts=@1;',...
		'Mask Help','Implements a sample-and-hold latch operating at the sampling interval you specify.')
set_param([sys,'/',['零阶采样',13,'保持器']],...
		'Mask Entries','.3\/',...
		'position',[50,319,80,351])

add_block('built-in/Discrete Zero-Pole',[sys,'/','z零极点传函'])
set_param([sys,'/','z零极点传函'],...
		'Poles','[0; 0.5]',...
		'position',[35,103,95,137])

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