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

📄 fchou.m

📁 信号实验常用的simulink模型和mfile,可直接在matlan下运行。
💻 M
字号:
function [ret,x0,str,ts,xts]=fchou(t,x,u,flag);
%FCHOU	is the M-file description of the SIMULINK system named FCHOU.
%	The block-diagram can be displayed by typing: FCHOU.
%
%	SYS=FCHOU(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 FCHOU 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 FCHOU with a FLAG of zero:
%	[SIZES]=FCHOU([],[],[],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',[4,85,628,460])
     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.00001')
set_param(sys,'Max step size', '0.01')
set_param(sys,'Relative error','1e-3')
set_param(sys,'Return vars',   '')


%     Subsystem  'Subsystem'.

new_system([sys,'/','Subsystem'])
set_param([sys,'/','Subsystem'],'Location',[15,110,245,305])

add_block('built-in/Sum',[sys,'/','Subsystem/Sum'])
set_param([sys,'/','Subsystem/Sum'],...
		'inputs','+-',...
		'position',[185,70,205,90])

add_block('built-in/Transport Delay',[sys,'/',['Subsystem/Transport',13,'Delay']])
set_param([sys,'/',['Subsystem/Transport',13,'Delay']],...
		'Delay Time','20',...
		'Buffer Size:','2048',...
		'position',[115,105,155,135])

add_block('built-in/Signal Generator',[sys,'/',['Subsystem/Signal',13,'Generator']])
set_param([sys,'/',['Subsystem/Signal',13,'Generator']],...
		'Peak','1.000000',...
		'Peak Range','5.000000',...
		'Freq','0.314159',...
		'Freq Range','5.000000',...
		'Wave','Sqr',...
		'Units','Rads',...
		'position',[50,58,95,92])

add_block('built-in/Outport',[sys,'/','Subsystem/out_1'])
set_param([sys,'/','Subsystem/out_1'],...
		'position',[235,70,255,90])
add_line([sys,'/','Subsystem'],[160,120;165,120;165,85;180,85])
add_line([sys,'/','Subsystem'],[100,75;110,120])
add_line([sys,'/','Subsystem'],[100,75;180,75])
add_line([sys,'/','Subsystem'],[210,80;230,80])


%     Finished composite block 'Subsystem'.

set_param([sys,'/','Subsystem'],...
		'position',[30,75,60,125])

add_block('built-in/MATLAB Fcn',[sys,'/','MATLAB Fcn'])
set_param([sys,'/','MATLAB Fcn'],...
		'MATLAB Fcn','fft(u,2048)',...
		'Output Width','2048',...
		'position',[120,83,180,117])

add_block('built-in/Scope',[sys,'/','Scope'])
set_param([sys,'/','Scope'],...
		'Vgain','2.360000',...
		'Hgain','20.000000',...
		'Vmax','4.720000',...
		'Hmax','40.000000',...
		'Window',[309,118,640,432],...
		'position',[90,0,120,30])

add_block('built-in/To Workspace',[sys,'/','To Workspace'])
set_param([sys,'/','To Workspace'],...
		'mat-name','x1',...
		'buffer','2048',...
		'position',[90,47,140,63])


%     Subsystem  ['Pulse',13,'Generator'].

new_system([sys,'/',['Pulse',13,'Generator']])
set_param([sys,'/',['Pulse',13,'Generator']],'Location',[158,441,759,682])

add_block('built-in/Outport',[sys,'/',['Pulse',13,'Generator/out_1']])
set_param([sys,'/',['Pulse',13,'Generator/out_1']],...
		'hide name',0,...
		'position',[560,105,580,125])

add_block('built-in/Gain',[sys,'/',['Pulse',13,'Generator/Gain']])
set_param([sys,'/',['Pulse',13,'Generator/Gain']],...
		'hide name',0,...
		'Gain','ht',...
		'position',[510,102,535,128])

add_block('built-in/Product',[sys,'/',['Pulse',13,'Generator/Product']])
set_param([sys,'/',['Pulse',13,'Generator/Product']],...
		'hide name',0,...
		'position',[455,105,480,125])

add_block('built-in/Logical Operator',[sys,'/',['Pulse',13,'Generator/Logical',13,'Operator1']])
set_param([sys,'/',['Pulse',13,'Generator/Logical',13,'Operator1']],...
		'Operator','NOT',...
		'Number of Input Ports','1',...
		'position',[355,38,385,62])

add_block('built-in/Logical Operator',[sys,'/',['Pulse',13,'Generator/Logical',13,'Operator']])
set_param([sys,'/',['Pulse',13,'Generator/Logical',13,'Operator']],...
		'Operator','XOR',...
		'position',[285,38,315,62])

add_block('built-in/Constant',[sys,'/',['Pulse',13,'Generator/Constant1']])
set_param([sys,'/',['Pulse',13,'Generator/Constant1']],...
		'Value','stt',...
		'position',[295,149,320,171])

add_block('built-in/Clock',[sys,'/',['Pulse',13,'Generator/Clock1']])
set_param([sys,'/',['Pulse',13,'Generator/Clock1']],...
		'hide name',0,...
		'position',[295,100,315,120])

add_block('built-in/Relational Operator',[sys,'/',['Pulse',13,'Generator/Relational',13,'operator']])
set_param([sys,'/',['Pulse',13,'Generator/Relational',13,'operator']],...
		'hide name',0,...
		'position',[370,102,400,133])

add_block('built-in/Sum',[sys,'/',['Pulse',13,'Generator/Sum1']])
set_param([sys,'/',['Pulse',13,'Generator/Sum1']],...
		'hide name',0,...
		'inputs','+-',...
		'position',[130,120,150,140])

add_block('built-in/Sum',[sys,'/',['Pulse',13,'Generator/Sum']])
set_param([sys,'/',['Pulse',13,'Generator/Sum']],...
		'hide name',0,...
		'inputs','+-',...
		'position',[135,35,155,55])

add_block('built-in/Constant',[sys,'/',['Pulse',13,'Generator/Constant']])
set_param([sys,'/',['Pulse',13,'Generator/Constant']],...
		'position',[25,30,45,50])

add_block('built-in/Unit Delay',[sys,'/',['Pulse',13,'Generator/Unit Delay']])
set_param([sys,'/',['Pulse',13,'Generator/Unit Delay']],...
		'orientation',2,...
		'Sample time','[Ts,st1]',...
		'position',[145,75,195,95])

add_block('built-in/Unit Delay',[sys,'/',['Pulse',13,'Generator/Unit Delay1']])
set_param([sys,'/',['Pulse',13,'Generator/Unit Delay1']],...
		'orientation',2,...
		'Sample time','[Ts,st2]',...
		'x0','ini',...
		'position',[140,165,190,185])
add_line([sys,'/',['Pulse',13,'Generator']],[390,50;430,50;430,110;450,110])
add_line([sys,'/',['Pulse',13,'Generator']],[320,50;350,50])
add_line([sys,'/',['Pulse',13,'Generator']],[325,160;345,160;345,125;365,125])
add_line([sys,'/',['Pulse',13,'Generator']],[540,115;555,115])
add_line([sys,'/',['Pulse',13,'Generator']],[485,115;505,115])
add_line([sys,'/',['Pulse',13,'Generator']],[405,120;450,120])
add_line([sys,'/',['Pulse',13,'Generator']],[320,110;365,110])
add_line([sys,'/',['Pulse',13,'Generator']],[140,85;105,85;105,50;130,50])
add_line([sys,'/',['Pulse',13,'Generator']],[160,45;230,45;230,85;200,85])
add_line([sys,'/',['Pulse',13,'Generator']],[50,40;130,40])
add_line([sys,'/',['Pulse',13,'Generator']],[155,130;210,130;210,175;195,175])
add_line([sys,'/',['Pulse',13,'Generator']],[135,175;100,175;100,135;125,135])
add_line([sys,'/',['Pulse',13,'Generator']],[50,40;70,40;70,125;125,125])
add_line([sys,'/',['Pulse',13,'Generator']],[160,45;280,45])
add_line([sys,'/',['Pulse',13,'Generator']],[155,130;245,130;245,55;280,55])
set_param([sys,'/',['Pulse',13,'Generator']],...
		'Mask Display','plot(0,0,100,100,[90,75,75,60,60,35,35,20,20,10],[20,20,80,80,20,20,80,80,20,20])',...
		'Mask Type','Pulse Generator')
set_param([sys,'/',['Pulse',13,'Generator']],...
		'Mask Dialogue','Pulse Generator.|Pulse period (secs):|Pulse width:|Pulse height:|Pulse start time:')
set_param([sys,'/',['Pulse',13,'Generator']],...
		'Mask Translate','Ts=@1; du=@2; ht=@3; stt=@4; ini=ones(length(ht),1); st1=rem(stt,Ts); st2=rem(stt+du,Ts);if(Ts<=1.2*du),ini=zeros(length(ht),1);end;')
set_param([sys,'/',['Pulse',13,'Generator']],...
		'Mask Help','Pulse generator which ensures pulse\ntransitions are hit. Provides a vector of pulses when the height is entered as a vector.\nUnmask to see how it works.')
set_param([sys,'/',['Pulse',13,'Generator']],...
		'Mask Entries','40\/0.01\/1\/0\/')


%     Finished composite block ['Pulse',13,'Generator'].

set_param([sys,'/',['Pulse',13,'Generator']],...
		'position',[25,177,60,213])

add_block('built-in/To Workspace',[sys,'/','To Workspace1'])
set_param([sys,'/','To Workspace1'],...
		'mat-name','x2',...
		'buffer','2048',...
		'position',[90,292,140,308])

add_block('built-in/Scope',[sys,'/','Scope1'])
set_param([sys,'/','Scope1'],...
		'Vgain','1.280000',...
		'Hgain','80.000000',...
		'Vmax','2.560000',...
		'Hmax','160.000000',...
		'Window',[0,76,331,390],...
		'position',[95,235,125,265])

add_block('built-in/MATLAB Fcn',[sys,'/','MATLAB Fcn1'])
set_param([sys,'/','MATLAB Fcn1'],...
		'MATLAB Fcn','fft(u,2048)',...
		'Output Width','2048',...
		'position',[115,178,175,212])


%     Subsystem  ['Inner',13,'Product'].

new_system([sys,'/',['Inner',13,'Product']])
set_param([sys,'/',['Inner',13,'Product']],'Location',[33,479,253,634])

add_block('built-in/Product',[sys,'/',['Inner',13,'Product/Product']])
set_param([sys,'/',['Inner',13,'Product/Product']],...
		'position',[65,55,90,75])

add_block('built-in/Sum',[sys,'/',['Inner',13,'Product/Sum']])
set_param([sys,'/',['Inner',13,'Product/Sum']],...
		'inputs','+',...
		'position',[125,55,145,75])

add_block('built-in/Outport',[sys,'/',['Inner',13,'Product/out_1']])
set_param([sys,'/',['Inner',13,'Product/out_1']],...
		'position',[185,55,205,75])

add_block('built-in/Inport',[sys,'/',['Inner',13,'Product/in_2']])
set_param([sys,'/',['Inner',13,'Product/in_2']],...
		'Port','2',...
		'position',[15,90,35,110])

add_block('built-in/Inport',[sys,'/',['Inner',13,'Product/in_1']])
set_param([sys,'/',['Inner',13,'Product/in_1']],...
		'position',[15,25,35,45])
add_line([sys,'/',['Inner',13,'Product']],[40,100;60,70])
add_line([sys,'/',['Inner',13,'Product']],[40,35;60,60])
add_line([sys,'/',['Inner',13,'Product']],[95,65;120,65])
add_line([sys,'/',['Inner',13,'Product']],[150,65;180,65])
set_param([sys,'/',['Inner',13,'Product']],...
		'Mask Display','.\n',...
		'Mask Type','Dot Product',...
		'Mask Dialogue','Inner (dot) product.\ny=sum(u1.*u2)')
set_param([sys,'/',['Inner',13,'Product']],...
		'Mask Help','Computes the inner (dot) product of the inputs: sum(u1.*u2).  The inputs are vectors of the same length. Output is a scalar.')


%     Finished composite block ['Inner',13,'Product'].

set_param([sys,'/',['Inner',13,'Product']],...
		'position',[245,94,265,116])

add_block('built-in/MATLAB Fcn',[sys,'/','MATLAB Fcn2'])
set_param([sys,'/','MATLAB Fcn2'],...
		'MATLAB Fcn','ifft',...
		'position',[300,88,360,122])

add_block('built-in/Scope',[sys,'/','Scope2'])
set_param([sys,'/','Scope2'],...
		'Vgain','5.300000',...
		'Hgain','40.800000',...
		'Vmax','10.600000',...
		'Hmax','81.600000',...
		'Window',[309,166,640,480],...
		'position',[390,5,420,35])

add_block('built-in/To Workspace',[sys,'/','To Workspace2'])
set_param([sys,'/','To Workspace2'],...
		'mat-name','x3',...
		'buffer','2048',...
		'position',[395,52,445,68])


%     Subsystem  'Subsystem1'.

new_system([sys,'/','Subsystem1'])
set_param([sys,'/','Subsystem1'],'Location',[15,110,245,305])

add_block('built-in/Outport',[sys,'/','Subsystem1/out_1'])
set_param([sys,'/','Subsystem1/out_1'],...
		'position',[235,70,255,90])

add_block('built-in/Signal Generator',[sys,'/',['Subsystem1/Signal',13,'Generator']])
set_param([sys,'/',['Subsystem1/Signal',13,'Generator']],...
		'Peak','1.000000',...
		'Peak Range','5.000000',...
		'Freq','0.157080',...
		'Freq Range','5.000000',...
		'Wave','Sqr',...
		'Units','Rads',...
		'position',[50,58,95,92])

add_block('built-in/Transport Delay',[sys,'/',['Subsystem1/Transport',13,'Delay']])
set_param([sys,'/',['Subsystem1/Transport',13,'Delay']],...
		'Delay Time','40',...
		'Buffer Size:','2048',...
		'position',[115,105,155,135])

add_block('built-in/Sum',[sys,'/','Subsystem1/Sum'])
set_param([sys,'/','Subsystem1/Sum'],...
		'inputs','+-',...
		'position',[185,70,205,90])
add_line([sys,'/','Subsystem1'],[210,80;230,80])
add_line([sys,'/','Subsystem1'],[100,75;180,75])
add_line([sys,'/','Subsystem1'],[100,75;110,120])
add_line([sys,'/','Subsystem1'],[160,120;165,120;165,85;180,85])


%     Finished composite block 'Subsystem1'.

set_param([sys,'/','Subsystem1'],...
		'position',[335,145,365,195])

add_block('built-in/Product',[sys,'/','Product'])
set_param([sys,'/','Product'],...
		'position',[420,98,450,122])

add_block('built-in/Scope',[sys,'/','Scope4'])
set_param([sys,'/','Scope4'],...
		'Vgain','1.480000',...
		'Hgain','20.000000',...
		'Vmax','2.960000',...
		'Hmax','40.000000',...
		'Window',[112,160,443,474],...
		'position',[490,95,520,125])

add_block('built-in/To Workspace',[sys,'/','To Workspace3'])
set_param([sys,'/','To Workspace3'],...
		'mat-name','x4',...
		'buffer','2048',...
		'position',[490,167,540,183])
add_line(sys,[65,100;115,100])
add_line(sys,[65,100;70,100;70,15;85,15])
add_line(sys,[70,55;85,55])
add_line(sys,[65,195;110,195])
add_line(sys,[75,195;85,300])
add_line(sys,[75,250;90,250])
add_line(sys,[180,195;225,195;225,110;240,110])
add_line(sys,[185,100;240,100])
add_line(sys,[270,105;295,105])
add_line(sys,[365,105;415,105])
add_line(sys,[375,105;385,20])
add_line(sys,[375,60;390,60])
add_line(sys,[370,170;385,170;385,115;415,115])
add_line(sys,[455,110;485,110])
add_line(sys,[465,110;465,175;485,175])

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