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

📄 lorenz2.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [ret,x0,str]=lorenz2(t,x,u,flag);
%LORENZ2	is the M-file description of the SIMULINK system named LORENZ2.
%	The block-diagram can be displayed by typing: LORENZ2.
%
%	SYS=LORENZ2(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 LORENZ2 to return state derivitives, FLAG=2
%	discrete states, FLAG=3 system outputs and FLAG=4 next sample
%	time. For more information and other options see SFUNC.
%
%	Calling LORENZ2 with a FLAG of zero:
%	[SIZES]=LORENZ2([],[],[],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.
%	For the definition of other parameters in SIZES, see SFUNC.
%	See also, TRIM, LINMOD, LINSIM, EULER, RK23, RK45, ADAMS, GEAR.

%	Copyright (c) 1990-94 by The MathWorks, Inc.

% 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',[0,0,479,423])
     open_system(sys)
end;
set_param(sys,'algorithm',		'RK-23')
set_param(sys,'Start time',	'0.0')
set_param(sys,'Stop time',		'999999')
set_param(sys,'Min step size',	'0.00001')
set_param(sys,'Max step size',	'10')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',	'')


%     Subsystem  ['Auto-scale storage',13,'graph scope'].

new_system([sys,'/',['Auto-scale storage',13,'graph scope']])
set_param([sys,'/',['Auto-scale storage',13,'graph scope']],'Location',[0,0,274,193])

add_block('built-in/S-function',[sys,'/',['Auto-scale storage',13,'graph scope/S-function',13,'M-file which plots',13,'lines',13,'']])
set_param([sys,'/',['Auto-scale storage',13,'graph scope/S-function',13,'M-file which plots',13,'lines',13,'']],...
		'function name','sfunyst',...
		'parameters','ax, color, npts',...
		'position',[130,55,180,75])

add_block('built-in/Inport',[sys,'/',['Auto-scale storage',13,'graph scope/x']])
set_param([sys,'/',['Auto-scale storage',13,'graph scope/x']],...
		'Port','1',...
		'position',[65,55,85,75])
add_line([sys,'/',['Auto-scale storage',13,'graph scope']],[90,65;125,65])
set_param([sys,'/',['Auto-scale storage',13,'graph scope']],...
		'Mask Display','plot(0,0,100,100,[83,76,63,52,42,38,28,16,11,84,11,11,11,90,90,11],[75,58,47,54,72,80,84,74,65,65,65,90,40,40,90,90])',...
		'Mask Type','Storage scope.')
set_param([sys,'/',['Auto-scale storage',13,'graph scope']],...
		'Mask Dialogue','Storage scope using MATLAB graph window.\nEnter plotting ranges and line type.|Initial Time Range:|Initial y-min:|Initial y-max:|Storage pts.:|Line type (rgbw-.:xo):')
set_param([sys,'/',['Auto-scale storage',13,'graph scope']],...
		'Mask Translate','npts = @4; color = @5; ax = [0, @1, @2, @3];')
set_param([sys,'/',['Auto-scale storage',13,'graph scope']],...
		'Mask Help','Uses MATLAB''s graph window.\nUse only one block per system.\nLine type must be in quotes.\nSee the M-file sfunyst.m.',...
		'Mask Entries','5\/-10\/10\/500\/''r-''\/')


%     Finished composite block ['Auto-scale storage',13,'graph scope'].

set_param([sys,'/',['Auto-scale storage',13,'graph scope']],...
		'Drop Shadow',4,...
		'position',[395,70,425,110])

add_block('built-in/Scope',[sys,'/','z Scope'])
set_param([sys,'/','z Scope'],...
		'ForeGround',0,...
		'Vgain','50.000000',...
		'Hgain','20.000000',...
		'Vmax','100.000000',...
		'Hmax','40.000000',...
		'Window',[0,0,280,220])
open_system([sys,'/','z Scope'])
set_param([sys,'/','z Scope'],...
		'position',[400,330,425,360])

add_block('built-in/Scope',[sys,'/','y Scope'])
set_param([sys,'/','y Scope'],...
		'ForeGround',0,...
		'Vgain','50.000000',...
		'Hgain','20.000000',...
		'Vmax','100.000000',...
		'Hmax','40.000000',...
		'Window',[0,0,280,220],...
		'position',[400,195,425,225])

add_block('built-in/Note',[sys,'/','Lorenz attractor'])
set_param([sys,'/','Lorenz attractor'],...
		'position',[190,20,191,21])

add_block('built-in/Note',[sys,'/','zdot'])
set_param([sys,'/','zdot'],...
		'position',[215,325,216,326])

add_block('built-in/Note',[sys,'/','ydot'])
set_param([sys,'/','ydot'],...
		'position',[210,190,211,191])

add_block('built-in/Note',[sys,'/','xdot'])
set_param([sys,'/','xdot'],...
		'position',[215,70,216,71])

add_block('built-in/Note',[sys,'/','z '])
set_param([sys,'/','z '],...
		'position',[290,325,291,326])

add_block('built-in/Note',[sys,'/','y '])
set_param([sys,'/','y '],...
		'position',[285,190,286,191])

add_block('built-in/Note',[sys,'/','x '])
set_param([sys,'/','x '],...
		'position',[290,70,291,71])

add_block('built-in/Gain',[sys,'/','Rho * x'])
set_param([sys,'/','Rho * x'],...
		'Gain','28',...
		'position',[70,244,105,266])

add_block('built-in/Product',[sys,'/','x * z'])
set_param([sys,'/','x * z'],...
		'inputs','2',...
		'position',[75,200,105,220])

add_block('built-in/Integrator',[sys,'/','Integrator1'])
set_param([sys,'/','Integrator1'],...
		'hide name',0,...
		'Initial','1',...
		'position',[240,200,270,220])

add_block('built-in/Sum',[sys,'/','Rx-y-xz'])
set_param([sys,'/','Rx-y-xz'],...
		'inputs','--+',...
		'position',[170,193,190,227])

add_block('built-in/Gain',[sys,'/','Beta * z'])
set_param([sys,'/','Beta * z'],...
		'Gain','2+2/3',...
		'position',[70,320,125,360])

add_block('built-in/Product',[sys,'/','x * y'])
set_param([sys,'/','x * y'],...
		'inputs','2',...
		'position',[75,375,105,395])

add_block('built-in/Sum',[sys,'/','-Bz+xy'])
set_param([sys,'/','-Bz+xy'],...
		'inputs','-+',...
		'position',[165,334,185,356])

add_block('built-in/Integrator',[sys,'/','Integrator2'])
set_param([sys,'/','Integrator2'],...
		'hide name',0,...
		'Initial','1',...
		'position',[245,335,275,355])

add_block('built-in/Integrator',[sys,'/','Integrator'])
set_param([sys,'/','Integrator'],...
		'hide name',0,...
		'Initial','1',...
		'position',[245,80,275,100])

add_block('built-in/Gain',[sys,'/','Sigma(y-x)'])
set_param([sys,'/','Sigma(y-x)'],...
		'Gain','10',...
		'position',[165,76,200,104])

add_block('built-in/Sum',[sys,'/','y - x'])
set_param([sys,'/','y - x'],...
		'inputs','-+',...
		'position',[105,79,125,101])
add_line(sys,[280,90;320,90;320,65;49,65;49,255;65,255])
add_line(sys,[320,90;390,90])
add_line(sys,[49,85;100,85])
add_line(sys,[49,255;49,380;70,380])
add_line(sys,[275,210;395,210])
add_line(sys,[275,210;295,210;295,175;15,175;15,390;70,390])
add_line(sys,[280,345;300,345;300,310;27,310;27,215;70,215])
add_line(sys,[280,90;320,90;320,65;49,65;49,205;70,205])
add_line(sys,[275,210;295,210;295,175;84,175;84,95;100,95])
add_line(sys,[275,210;295,210;295,175;120,175;120,200;165,200])
add_line(sys,[110,210;165,210])
add_line(sys,[110,255;120,255;120,220;165,220])
add_line(sys,[195,210;235,210])
add_line(sys,[110,385;145,385;145,350;160,350])
add_line(sys,[130,340;160,340])
add_line(sys,[190,345;240,345])
add_line(sys,[280,345;300,345;300,310;27,310;27,340;65,340])
add_line(sys,[130,90;160,90])
add_line(sys,[205,90;240,90])
add_line(sys,[280,345;395,345])
% Return any arguments.
if (nargin | nargout)
	% Must use feval here to access system in memory
	if (nargin > 3)
		if (flag == 0)
			eval(['[ret,x0,xstr]=',sys,'(t,x,u,flag);'])
		else
			eval(['ret =', sys,'(t,x,u,flag);'])
		end
	else
		[ret,x0,str] = feval(sys);
	end
end

⌨️ 快捷键说明

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