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

📄 sources.m

📁 数字通信第四版原书的例程
💻 M
字号:
function [ret,x0,str]=sources(t,x,u,flag);
%SOURCES	is the M-file description of the SIMULINK system named SOURCES.
%	The block-diagram can be displayed by typing: SOURCES.
%
%	SYS=SOURCES(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 SOURCES 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 SOURCES with a FLAG of zero:
%	[SIZES]=SOURCES([],[],[],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,56,355,545])
     open_system(sys)
end;
set_param(sys,'algorithm',		'RK-45')
set_param(sys,'Start time',	'0.0')
set_param(sys,'Stop time',		'100')
set_param(sys,'Min step size',	'0.01')
set_param(sys,'Max step size',	'.05')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',	'')

add_block('built-in/Note',[sys,'/','Signal Sources'])
set_param([sys,'/','Signal Sources'],...
		'position',[175,10,176,11])

add_block('built-in/Sine Wave',[sys,'/','Sine Wave'])
set_param([sys,'/','Sine Wave'],...
		'position',[70,110,100,140])

add_block('built-in/Step Fcn',[sys,'/','Step Fcn'])
set_param([sys,'/','Step Fcn'],...
		'position',[70,49,100,81])

add_block('built-in/White Noise',[sys,'/','White Noise'])
set_param([sys,'/','White Noise'],...
		'position',[70,170,100,200])

add_block('built-in/From Workspace',[sys,'/','From Workspace'])
set_param([sys,'/','From Workspace'],...
		'matl_expr','[1 3 7 15 20 100; 0 10 -5 5 -20 3]''',...
		'position',[20,284,235,316])

add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
		'Peak','1.000000',...
		'Peak Range','1.000000',...
		'Freq','3.000000',...
		'Freq Range','3.000000',...
		'Wave','Saw',...
		'Units','Rads',...
		'position',[65,223,110,257])

add_block('built-in/Clock',[sys,'/','Clock'])
set_param([sys,'/','Clock'],...
		'position',[60,342,100,378])

add_block('built-in/Constant',[sys,'/','Constant'])
set_param([sys,'/','Constant'],...
		'position',[65,417,95,443])

add_block('built-in/Scope',[sys,'/','Sine Scope'])
set_param([sys,'/','Sine Scope'],...
		'Vgain','2.000000',...
		'Hgain','20.000000',...
		'Vmax','2.000000',...
		'Hmax','40.000000',...
		'Window',[359,192,569,313],...
		'position',[250,110,275,140])

add_block('built-in/Scope',[sys,'/','Random Scope'])
set_param([sys,'/','Random Scope'],...
		'Vgain','5.000000',...
		'Hgain','3.000000',...
		'Vmax','10.000000',...
		'Hmax','6.000000',...
		'Window',[362,301,571,417],...
		'position',[250,170,275,200])

add_block('built-in/Scope',[sys,'/','Matrix Scope'])
set_param([sys,'/','Matrix Scope'],...
		'Vgain','30.000000',...
		'Hgain','5.000000',...
		'Vmax','60.000000',...
		'Hmax','10.000000',...
		'Window',[360,468,580,602],...
		'position',[270,285,295,315])

add_block('built-in/Scope',[sys,'/','Clock Scope'])
set_param([sys,'/','Clock Scope'],...
		'Vgain','100.000000',...
		'Hgain','100.000000',...
		'Vmax','200.000000',...
		'Hmax','200.000000',...
		'Window',[370,553,581,694],...
		'position',[250,345,275,375])

add_block('built-in/Scope',[sys,'/','Constant Scope'])
set_param([sys,'/','Constant Scope'],...
		'Vgain','5.000000',...
		'Hgain','10.000000',...
		'Vmax','10.000000',...
		'Hmax','20.000000',...
		'Window',[369,621,581,748],...
		'position',[250,415,275,445])

add_block('built-in/Scope',[sys,'/','Step Scope'])
set_param([sys,'/','Step Scope'],...
		'Vgain','2.000000',...
		'Hgain','10.000000',...
		'Vmax','2.000000',...
		'Hmax','20.000000',...
		'Window',[355,129,565,274],...
		'position',[250,50,275,80])

add_block('built-in/Scope',[sys,'/','Signal Scope'])
set_param([sys,'/','Signal Scope'],...
		'Vgain','2.000000',...
		'Hgain','5.000000',...
		'Vmax','2.000000',...
		'Hmax','10.000000',...
		'Window',[362,406,570,513],...
		'position',[250,225,275,255])
add_line(sys,[105,65;240,65])
add_line(sys,[105,125;240,125])
add_line(sys,[105,185;240,185])
add_line(sys,[115,240;240,240])
add_line(sys,[240,300;260,300])
add_line(sys,[105,360;240,360])
add_line(sys,[100,430;240,430])
% 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]=',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 + -