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

📄 lab02.m

📁 xnsy算法的matlab实现
💻 M
字号:
function [ret,x0,str,ts,xts]=lab02(t,x,u,flag);
%LAB02	is the M-file description of the SIMULINK system named LAB02.
%	The block-diagram can be displayed by typing: LAB02.
%
%	SYS=LAB02(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 LAB02 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 LAB02 with a FLAG of zero:
%	[SIZES]=LAB02([],[],[],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',[13,120,145,456])
     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,'/','输出设备'])
set_param([sys,'/','输出设备'],...
		'ForeGround',4,...
		'Font Size',14,...
		'position',[70,15,75,20])

add_block('built-in/Scope',[sys,'/','示波器'])
set_param([sys,'/','示波器'],...
		'Vgain','1.000000',...
		'Hgain','1.000000',...
		'Vmax','2.000000',...
		'Hmax','2.000000',...
		'Window',[387,195,745,507],...
		'position',[60,60,85,90])


%     Subsystem  'XY 示波器'.

new_system([sys,'/','XY 示波器'])
set_param([sys,'/','XY 示波器'],'Location',[8,52,282,245])

add_block('built-in/Inport',[sys,'/','XY 示波器/y'])
set_param([sys,'/','XY 示波器/y'],...
		'Port','2',...
		'position',[10,100,30,120])

add_block('built-in/Inport',[sys,'/','XY 示波器/x'])
set_param([sys,'/','XY 示波器/x'],...
		'position',[10,30,30,50])

add_block('built-in/Mux',[sys,'/','XY 示波器/Mux'])
set_param([sys,'/','XY 示波器/Mux'],...
		'inputs','2',...
		'position',[100,61,130,94])

add_block('built-in/S-Function',[sys,'/',['XY 示波器/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['XY 示波器/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunxy',...
		'parameters','ax, st',...
		'position',[185,70,235,90])
add_line([sys,'/','XY 示波器'],[35,110;70,110;70,85;95,85])
add_line([sys,'/','XY 示波器'],[35,40;70,40;70,70;95,70])
add_line([sys,'/','XY 示波器'],[135,80;180,80])
set_param([sys,'/','XY 示波器'],...
		'Mask Display','plot(0,0,100,100,[12,91,91,12,12],[90,90,45,45,90],[51,57,65,75,80,79,75,67,60,54,51,48,42,34,28,27,31,42,51],[71,68,66,66,72,79,83,84,81,77,71,60,54,54,58,65,71,74,71])')
set_param([sys,'/','XY 示波器'],...
		'Mask Type','XY scope.',...
		'Mask Dialogue','XY scope using MATLAB graph window.\nFirst input is used as time base.\nEnter plotting ranges.|x-min:|x-max:|y-min:|y-max:')
set_param([sys,'/','XY 示波器'],...
		'Mask Translate','ax = [@1, @2, @3, @4];st=-1;',...
		'Mask Help','This block can be used to explore limit cycles. Look at the m-file sfunxy.m to see how it works.',...
		'Mask Entries','-10\/10\/-10\/10\/')


%     Finished composite block 'XY 示波器'.

set_param([sys,'/','XY 示波器'],...
		'position',[55,126,85,164])

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