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

📄 penddemo.m

📁 数字通信第四版原书的例程
💻 M
📖 第 1 页 / 共 2 页
字号:
		'position',[540,126,585,144])

add_block('built-in/Mux',[sys,'/',['Limited ',13,'Integrator/Mux']])
set_param([sys,'/',['Limited ',13,'Integrator/Mux']],...
		'inputs','2',...
		'position',[85,116,115,149])
add_line([sys,'/',['Limited ',13,'Integrator']],[680,135;715,135])
add_line([sys,'/',['Limited ',13,'Integrator']],[45,140;80,140])
add_line([sys,'/',['Limited ',13,'Integrator']],[120,135;145,135])
add_line([sys,'/',['Limited ',13,'Integrator']],[525,135;535,135])
add_line([sys,'/',['Limited ',13,'Integrator']],[590,135;625,135])
add_line([sys,'/',['Limited ',13,'Integrator']],[600,135;600,35;55,35;55,125;80,125])
set_param([sys,'/',['Limited ',13,'Integrator']],...
		'Mask Display','plot(-1,-0.2,3.5,1.2,[0.05,1,2,2.9],[0,0,1,1]); 1/s    ',...
		'Mask Type','Limited integrator.')
set_param([sys,'/',['Limited ',13,'Integrator']],...
		'Mask Dialogue','Limited integrator|Lower bound:|Upper bound:|Initial condition',...
		'Mask Translate','lb = @1; ub = @2; xi = @3;')
set_param([sys,'/',['Limited ',13,'Integrator']],...
		'Mask Help','Implements a limited integrator with \nan expression of the form:\n\nif(x<=lb and u<0) or (x>=ub and u>0)\n\txdot=0\nelse\n\txdot=u.',...
		'Mask Entries','-5\/5\/0\/')


%     Finished composite block ['Limited ',13,'Integrator'].

set_param([sys,'/',['Limited ',13,'Integrator']],...
		'position',[250,113,285,147])

add_block('built-in/Signal Generator',[sys,'/','Signal Gen.'])
set_param([sys,'/','Signal Gen.'],...
		'hide name',0,...
		'Peak','0.000000',...
		'Peak Range','Inf',...
		'Freq','0.400000',...
		'Freq Range','2.000000',...
		'Wave','Sqr',...
		'Units','Rads',...
		'position',[10,113,55,147])

add_block('built-in/Constant',[sys,'/','Constant'])
set_param([sys,'/','Constant'],...
		'Value','-5.099',...
		'position',[10,180,60,200])

add_block('built-in/Sum',[sys,'/','Sum3'])
set_param([sys,'/','Sum3'],...
		'hide name',0,...
		'position',[85,125,105,145])

add_block('built-in/Saturation',[sys,'/','Saturation'])
set_param([sys,'/','Saturation'],...
		'hide name',0,...
		'Lower Limit','-10',...
		'Upper Limit','10',...
		'position',[380,125,405,145])


%     Subsystem  'Discrete State Estimator'.

new_system([sys,'/','Discrete State Estimator'])
set_param([sys,'/','Discrete State Estimator'],'Location',[380,440,840,612])

add_block('built-in/Discrete State-Space',[sys,'/','Discrete State Estimator/Dis. State-space'])
set_param([sys,'/','Discrete State Estimator/Dis. State-space'],...
		'A','zeros(2)',...
		'B','-eye(2)/Ts',...
		'C','[0 0; 1 0; 0 0; 0 1]',...
		'D','[1 0; 1/Ts 0; 0 1; 0 1/Ts]',...
		'Sample time','Ts',...
		'position',[115,65,235,105])

add_block('built-in/Mux',[sys,'/','Discrete State Estimator/Mux2'])
set_param([sys,'/','Discrete State Estimator/Mux2'],...
		'hide name',0,...
		'inputs','2',...
		'position',[55,55,80,110])

add_block('built-in/Inport',[sys,'/','Discrete State Estimator/in_1'])
set_param([sys,'/','Discrete State Estimator/in_1'],...
		'position',[15,60,35,80])

add_block('built-in/Outport',[sys,'/','Discrete State Estimator/out_1'])
set_param([sys,'/','Discrete State Estimator/out_1'],...
		'position',[260,75,280,95])

add_block('built-in/Inport',[sys,'/','Discrete State Estimator/in_2'])
set_param([sys,'/','Discrete State Estimator/in_2'],...
		'Port','2',...
		'position',[15,85,35,105])
add_line([sys,'/','Discrete State Estimator'],[85,85;110,85])
add_line([sys,'/','Discrete State Estimator'],[40,70;50,70])
add_line([sys,'/','Discrete State Estimator'],[240,85;255,85])
add_line([sys,'/','Discrete State Estimator'],[40,95;50,95])
set_param([sys,'/','Discrete State Estimator'],...
		'Mask Display','',...
		'Mask Type','Pendulum Discrete state estimator',...
		'Mask Dialogue','Pendulum discrete state estimator|Sample time',...
		'Mask Translate','Ts = @1;')
set_param([sys,'/','Discrete State Estimator'],...
		'Mask Help','The states of the pendulum and cart system are the pendulum angle and angular velocity and cart position and velocity.  Since the sensors output the pendulum angle and cart position, this state estimator just does a one step difference calculation to get the velocities.')
set_param([sys,'/','Discrete State Estimator'],...
		'Mask Entries','0.02\/')


%     Finished composite block 'Discrete State Estimator'.

set_param([sys,'/','Discrete State Estimator'],...
		'position',[530,157,560,208])

add_block('built-in/State-Space',[sys,'/','Matrix gain.'])
set_param([sys,'/','Matrix gain.'],...
		'hide name',0,...
		'A','[]',...
		'B','[]',...
		'C','[]',...
		'D','K',...
		'Mask Display','LQR',...
		'Mask Type','Matrix gain',...
		'Mask Dialogue','Matrix Gain:|Gain matrix:')
set_param([sys,'/','Matrix gain.'],...
		'Mask Translate','K = @1;',...
		'Mask Help','Multiplies input vector by entered matrix to produce output vector.',...
		'Mask Entries','[0 -18 -166.5 -15.2]\/',...
		'position',[585,169,650,201])

add_block('built-in/Note',[sys,'/',['To start and stop the simulation, use the "Start//Stop"',13,'selection in the "Simulation" pull-down menu']])
set_param([sys,'/',['To start and stop the simulation, use the "Start//Stop"',13,'selection in the "Simulation" pull-down menu']],...
		'position',[179,310,184,315])


%     Subsystem  'More Info'.

new_system([sys,'/','More Info'])
set_param([sys,'/','More Info'],'Location',[127,169,475,352])

add_block('built-in/Note',[sys,'/',['More Info/This system simulates a cart carrying an inverted',13,'pendulum and displays an animation.']])
set_param([sys,'/',['More Info/This system simulates a cart carrying an inverted',13,'pendulum and displays an animation.']],...
		'position',[160,15,165,20])

add_block('built-in/Note',[sys,'/',['More Info/The animation is created using MATLAB''s ',13,'Handle Graphics. The animation block is ',13,'just a masked S-function.']])
set_param([sys,'/',['More Info/The animation is created using MATLAB''s ',13,'Handle Graphics. The animation block is ',13,'just a masked S-function.']],...
		'position',[160,60,165,65])

add_block('built-in/Note',[sys,'/',['More Info/For more information on what the S-function ',13,'does, look at the functions pendan.m, pend0.m, ',13,'and pendsets.m.']])
set_param([sys,'/',['More Info/For more information on what the S-function ',13,'does, look at the functions pendan.m, pend0.m, ',13,'and pendsets.m.']],...
		'position',[160,115,165,120])
set_param([sys,'/','More Info'],...
		'Mask Display','?')


%     Finished composite block 'More Info'.

set_param([sys,'/','More Info'],...
		'hide name',0,...
		'Drop Shadow',4,...
		'position',[330,270,357,295])


%     Subsystem  'More Info2'.

new_system([sys,'/','More Info2'])
set_param([sys,'/','More Info2'],'Location',[128,280,487,453])

add_block('built-in/Note',[sys,'/',['More Info2/This system models a double pendulum system where',13,'the rest state has both pendulums hanging vertically.']])
set_param([sys,'/',['More Info2/This system models a double pendulum system where',13,'the rest state has both pendulums hanging vertically.']],...
		'position',[168,20,173,25])

add_block('built-in/Note',[sys,'/',['More Info2/Associated with the demo is an animation function that',13,'will automatically open a figure window and display to it.']])
set_param([sys,'/',['More Info2/Associated with the demo is an animation function that',13,'will automatically open a figure window and display to it.']],...
		'position',[174,65,179,70])

add_block('built-in/Note',[sys,'/',['More Info2/Try experimenting with different initial conditions for',13,'alpha and gamma to see the unusal coupling effects.']])
set_param([sys,'/',['More Info2/Try experimenting with different initial conditions for',13,'alpha and gamma to see the unusal coupling effects.']],...
		'position',[175,115,180,120])
set_param([sys,'/','More Info2'],...
		'Mask Display','Double click\nhere for\nSIMULINK Help',...
		'Mask Dialogue','eval(''[cs,cb]=get_param;str=[''''simcad '''' cs];eval(str);'')')


%     Finished composite block 'More Info2'.

set_param([sys,'/','More Info2'],...
		'hide name',0,...
		'Drop Shadow',4,...
		'position',[395,270,497,321])

add_block('built-in/Clock',[sys,'/','Clock'])
set_param([sys,'/','Clock'],...
		'position',[540,275,560,295])

add_block('built-in/To Workspace',[sys,'/','To Workspace1'])
set_param([sys,'/','To Workspace1'],...
		'mat-name','t',...
		'buffer','[1000 1 0.1]',...
		'position',[595,277,645,293])
add_line(sys,[410,135;420,135])
add_line(sys,[460,145;505,145;505,195;525,195])
add_line(sys,[460,120;515,120;525,170])
add_line(sys,[565,185;580,185])
add_line(sys,[460,120;460,45;125,45;135,125])
add_line(sys,[110,135;135,135])
add_line(sys,[290,130;335,130])
add_line(sys,[655,185;665,185;665,235;320,235;320,150;335,150])
add_line(sys,[60,130;80,130])
add_line(sys,[65,190;65,140;80,140])
add_line(sys,[110,135;110,200;185,200])
add_line(sys,[250,200;305,200;305,140;335,140])
add_line(sys,[250,75;305,75;305,120;335,120])
add_line(sys,[365,135;375,135])
add_line(sys,[165,130;165,75;195,75])
add_line(sys,[235,130;245,130])
add_line(sys,[165,130;180,130])
add_line(sys,[110,135;110,35;520,35])
add_line(sys,[475,120;475,45;520,45])
add_line(sys,[495,145;495,55;520,55])
add_line(sys,[560,45;605,45])
add_line(sys,[570,45;570,105;610,105])
add_line(sys,[565,285;590,285])

% 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
end

⌨️ 快捷键说明

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