




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、matlab练习题和答案控制系统仿真实验 Matlab部分实验结果 目 录 实验一 MATLAB基本操作 . 1 实验二 Matlab编程 . 5 实验三 Matlab底层图形控制 . 6 实验四 控制系统古典分析.12 实验五 控制系统现代分析 .15 实验六 PID控制器的设计 .19 实验七 系统状态空间设计.23 实验九 直流双闭环调速系统仿真 .25 实验一 MATLAB基本操作 1 用MATLAB可以识别的格式输入下面两个矩阵 1233,1443678,i,,2357,2335542,i, A,1357B,2675342,i,3239,189543,,1894,再求出它们的乘积矩阵
2、C,并将C矩阵的右下角2×3子矩阵赋给D矩阵。赋值完成后,调用相应的命令查看MATLAB工作空间的占用情况。 A=1,2,3,3;2,3,5,7;1,3,5,7;3,2,3,9;1,8,9,4; B=1+4i,4,3,6,7,8;2,3,3,5,5,4+2i;2,6+7i,5,3,4,2;1,8,9,5,4,3; C=A*B; D=C(4:5,4:6); whos Name Size Bytes Class Attributes A 5x4 160 double B 4x6 384 double complex C 5x6 480 double complex D 2x3 96 do
3、uble complex 2 选择合适的步距绘制出下面的图形 ,其中 sin(/)1tt,(,)11t=-1:0.1:1; y=sin(1./t); plot(t,y) 1 3 对下面给出的各个矩阵求取矩阵的行列式、秩、特征多项式、范数、特征根、特征向量和逆矩阵。 5765753500.,,71087833410.,, B,A,681090910315,.,579100037193.,12343324,,,56785518,, C,D,910111211857,1,,A=7.5,3.5,0,0;8,33,4.1,0;0,9,103,-1.5;0,0,3.7,19.3; B=5,7,6,5;7,
4、10,8,7;6,8,10,9;5,7,9,10; C=1:4;5:8;9:12;13:1rtf6; D=3,-3,-2,4;5,-5,1,8;11,8,5,-7;5,-1,-3,-1; det(A);det(B);det(C);det(D); rank(A); rank(B); rank(C); rank(D); a=poly(A); b=poly(B); c=poly(C); d=poly(D); norm(A); 2 norm(B); norm(C); norm(D); v,d=eig(A,'nobalance'); v,d=eig(B,'nobalance
5、9;); v,d=eig(C,'nobalance'); v,d=eig(D,'nobalance'); m=inv(A); n=inv(B); p=inv(C); q=inv(D); 4 求解下面的线性代数方程,并验证得出的解真正满足原方程。 72124,1321390,,721264,915327,(a),(b) X,X,91532117,221151,2211521132130,(a) A=7,2,1,-2;9,15,3,-2;-2,-2,11,5;1,3,2,13; B=4;7;-1;0; X=AB; C=A*X; (b) A=1,3,2,13;7,2,
6、1,-2;9,15,3,-2;-2,-2,11,5; B=9,0;6,4;11,7;-2,-1; X=AB; C=A*X; 5. (1) 初始化一10*10矩阵,其元素均为1 ones(10,10); (2) 初始化一10*10矩阵,其元素均为0 zeros(10,10); (3) 初始化一10*10对角矩阵 v=1:10; diag(v); (4) 输入A=7 1 5;2 5 6;3 1 5,B=1 1 1; 2 2 2; 3 3 3,执行下列命令,理解其含义 A(2, 3) 表示取A矩阵第2行、第3列的元素; 3 A(:,2) 表示取A矩阵的第,列全部元素; A(3,:) 表示取A矩阵第,
7、行的全部元素; A(:,1:2:3)表示取A矩阵第1、3列的全部元素; A(:,3).*B(:,2)表示A矩阵第3列的元素点乘B矩阵第2列的元素 A(:,3)*B(2,:)表示A矩阵第3列的元素乘以B矩阵第2行 A*B 矩阵AB相乘 A.*B矩阵A点乘矩阵B A2矩阵A的平方 A.2矩阵表示求矩阵A的每一个元素的平方值 B/A 表示方程AX=B的解X B./A表示矩阵B的每一个元素点除矩阵A的元素 6在同一坐标系中绘制余弦曲线y=cos(t-0.25)和正弦曲线y=sin(t-0.5),t?0,2,用不同颜色,不同线的类型予以表示,注意坐标轴的比例控制。 t=0:0.01:2*pi; y1=c
8、os(t-0.25); plot(t,y1,'r-') hold on y2=sin(t-0.5); plot(t,y2,'k') 4 实验二 Matlab编程 1分别用for和while循环结构编写程序,求出 63i236263 K,,2122222?,i0并考虑一种避免循环的简洁方法来进行求和。 (a)j=1;n=0;sum=1; for n=n+1:63 for i=1:n j=j*2; end sum=sum+j; j=1; end sum (b)j=1;n=1;sum=1; while n=64 i=1; while i<n+1 j=j*2; i
9、=i+1; end n=n+1; sum=sum+j; j=1; end Sum (c)i=0:63;k=sum(2.i); 2计算 1+2+n<2000 时的最大 n 值 s=0;m=0;while(s<=2000),m=m+1;s=s+m;end,m 3 用MATLAB语言实现下面的分段函数 ,hxD, yfxhDx,()/,xD,hxD,存放于文件ff.m中,令D=3,h=1求出,f(-1.5), f(0.5), f(5). D=3;h=1; x=-2*D:1/2:2*D; y=-h*(x<-D)+h/D./x.*(x>=-D)&(x<=D)+h*(
10、x>D); 5 plot(x,y); grid on f1=y(find(x=-1.5) f2=y(find(x=0.5) f3=y(find(x=5) 实验三 Matlab底层图形控制 1 在MATLAB命令行中编程得到y=sin(t)和y1=cos(t)函数, plot(t,y);figure(10);plot(t,y1); >> t=-pi:0.05:pi; >> y=sin(t); >> y1=cos(t); >> plot(t,y) >> figure(10); >> plot(t,y1) 2 在MATLA
11、B命令行中键入h=get(0),查看根屏幕的属性,h此时为根屏幕句柄的符号表示,0为根屏幕对应的标号。 >> h=get(0) h = BeingDeleted: 'off' BusyAction: 'queue' ButtonDownFcn: '' CallbackObject: Children: 2x1 double Clipping: 'on' CommandWindowSize: 89 27 CreateFcn: '' CurrentFigure: 1 DeleteFcn: ''
12、; Diary: 'off' DiaryFile: 'diary' Echo: 'off' FixedWidthFontName: 'Courier New' Format: 'short' FormatSpacing: 'loose' HandleVisibility: 'on' HitTest: 'on' Interruptible: 'on' Language: 'zh_cn.gbk' MonitorPositions: 1 1
13、1440 900 More: 'off' 6 Parent: PointerLocation: 1048 463 PointerWindow: 0 RecursionLimit: 500 ScreenDepth: 32 ScreenPixelsPerInch: 96 ScreenSize: 1 1 1440 900 Selected: 'off' SelectionHighlight: 'on' ShowHiddenHandles: 'off' Tag: '' Type: 'root' UICont
14、extMenu: Units: 'pixels' UserData: Visible: 'on' 3 h1=get(1);h2=get(10), 1, 10分别为两图形窗口对应标号,其中1为Matlab自动分配,标号10已在figure(10)中指定。查看h1和h2属性,注意CurrentAxes和CurrenObject属性。 >> h1=get(1) h1 = Alphamap: 1x64 double BeingDeleted: 'off' BusyAction: 'queue' ButtonDownFcn: &
15、#39;' Children: 170.0012 Clipping: 'on' CloseRequestFcn: 'closereq' Color: 0.8000 0.8000 0.8000 Colormap: 64x3 double CreateFcn: '' CurrentAxes: 170.0012 CurrentCharacter: '' CurrentObject: CurrentPoint: 0 0 DeleteFcn: '' DockControls: 'on' FileNam
16、e: '' FixedColors: 10x3 double HandleVisibility: 'on' HitTest: 'on' IntegerHandle: 'on' Interruptible: 'on' InvertHardcopy: 'on' 7 KeyPressFcn: '' KeyReleaseFcn: '' MenuBar: 'figure' MinColormap: 64 Name: '' NextPlot:
17、39;add' NumberTitle: 'on' PaperOrientation: 'portrait' PaperPosition: 0.6345 6.3452 20.3046 15.2284 PaperPositionMode: 'manual' PaperSize: 20.9840 29.6774 PaperType: 'A4' PaperUnits: 'centimeters' Parent: 0 Pointer: 'arrow' PointerShapeCData: 16x16
18、 double PointerShapeHotSpot: 1 1 Position: 440 378 560 420 Renderer: 'painters' RendererMode: 'auto' Resize: 'on' ResizeFcn: '' Selected: 'off' SelectionHighlight: 'on' SelectionType: 'normal' Tag: '' ToolBar: 'auto' Type: '
19、figure' UIContextMenu: Units: 'pixels' UserData: Visible: 'on' WindowButtonDownFcn: '' WindowButtonMotionFcn: '' WindowButtonUpFcn: '' WindowKeyPressFcn: '' WindowKeyReleaseFcn: '' WindowScrollWheelFcn: '' WindowStyle: 'normal
20、39; WVisual: '00 (RGB 32 GDI, Bitmap, Window)' WVisualMode: 'auto' >> h2=get(10) h2 = 8 Alphamap: 1x64 double BeingDeleted: 'off' BusyAction: 'queue' ButtonDownFcn: '' Children: 342.0011 Clipping: 'on' CloseRequestFcn: 'closereq' Color: 0
21、.8000 0.8000 0.8000 Colormap: 64x3 double CreateFcn: '' CurrentAxes: 342.0011 CurrentCharacter: '' CurrentObject: CurrentPoint: 0 0 DeleteFcn: '' DockControls: 'on' FileName: '' FixedColors: 10x3 double HandleVisibility: 'on' HitTest: 'on' Inte
22、gerHandle: 'on' Interruptible: 'on' InvertHardcopy: 'on' KeyPressFcn: '' KeyReleaseFcn: '' MenuBar: 'figure' MinColormap: 64 Name: '' NextPlot: 'add' NumberTitle: 'on' PaperOrientation: 'portrait' PaperPosition: 0.6345 6
23、.3452 20.3046 15.2284 PaperPositionMode: 'manual' PaperSize: 20.9840 29.6774 PaperType: 'A4' PaperUnits: 'centimeters' Parent: 0 Pointer: 'arrow' PointerShapeCData: 16x16 double PointerShapeHotSpot: 1 1 Position: 440 378 560 420 Renderer: 'painters' RendererMo
24、de: 'auto' Resize: 'on' ResizeFcn: '' 9 Selected: 'off' SelectionHighlight: 'on' SelectionType: 'normal' Tag: '' ToolBar: 'auto' Type: 'figure' UIContextMenu: Units: 'pixels' UserData: Visible: 'on' WindowButtonD
25、ownFcn: '' WindowButtonMotionFcn: '' WindowButtonUpFcn: '' WindowKeyPressFcn: '' WindowKeyReleaseFcn: '' WindowScrollWheelFcn: '' WindowStyle: 'normal' WVisual: '00 (RGB 32 GDI, Bitmap, Window)' WVisualMode: 'auto' 4 输入h.Childre
26、n,观察结果。 >> h.Children ans = 1 10 5 键入gcf,得到当前图像句柄的值,分析其结果及h,h1,h2中哪个一致,为什么? ans = 1 结果及h的一致 6 鼠标点击Figure 1窗口,让其位于前端,在命令行中键入gcf,观察此时的值,和上一步中有何不同,为什么? ans = 1 7 观察h1.Children和h2.Children,gca的值。 >> h1.Children ans = 170.0012 10 >> h2.Children ans = 342.0011 >> gca ans = 170.0012
27、 8 观察以下程序结果h3=h1.Children; set(h3,'Color','green');h3_1=get(h3,'children');set(h3_1, 'Color','red'); 其中h3_1为Figure1中线对象句柄,不能直接采用h3_1=h3.Children命令获得。 9 命令行中键入plot(t,sin(t-pi/3),观察曲线出现在哪个窗口。h4=h2.Children;axes(h4); plot(t,sin(t-pi/3),看看此时曲线显示在何窗口。 plot(t,sin(t-
28、pi/3)后,曲线出现在figure1窗口;h4=h2.Children;axes(h4); plot(t,sin(t-pi/3)后,曲线出现在figure10 11 实验四 控制系统古典分析 103G(s),(已知二阶系统 2s,2s,10(1) 编写程序求解系统的阶跃响应; a=sqrt(10); zeta=(1/a); num=10; den=1 2*zeta*a 10; sys=tf(num,den); t=0:0.01:3; figure(1) step(sys,t);grid 修改参数,实现和的阶跃响应; ,1,2时: ,1a=sqrt(10); zeta=1; num=10; d
29、en=1 2*zeta*a 10; sys=tf(num,den); t=0:0.01:3; figure(1) step(sys,t);grid 时: ,2a=sqrt(10); zeta=2; num=10; den=1 2*zeta*a 10; sys=tf(num,den); t=0:0.01:3; figure(1) step(sys,t);grid 1,2,10修改参数,实现和的阶跃响应() n1nn2nn21,时: n1n212 a=sqrt(10); zeta=(1/a); num=0.25; den=1 2*zeta*0.5*a 0.25; sys=tf(num,den);
30、t=0:0.01:3; figure(1) step(sys,t);grid 时: ,2,n2na=sqrt(10); zeta=(1/a); num=40; den=1 2*zeta*2*a 40; sys=tf(num,den); t=0:0.01:3; figure(1) step(sys,t);grid (2) 试做出以下系统的阶跃响应,并比较及原系统响应曲线的差别及特点,作出相应的实验分析结果。 222s,10s,0.5s,10s,0.5sG(s),G(s),G(s), ; 123222s,2s,10s,2s,10s,2s,10sG(s), 22s,2s,10要求:分析系统的阻尼比和
31、无阻尼振荡频率对系统阶跃响应的影响; 分析响应曲线的零初值、非零初值及系统模型的关系; 分析响应曲线的稳态值及系统模型的关系; 分析系统零点对阶跃响应的影响; a=sqrt(10); zeta=(1/a); num=10; den=1 2*zeta*a 10; sys=tf(num,den); t=0:0.01:3; step(sys,t); hold on num1=0 2 10; sys1=tf(num1,den); step(sys1,t); num2=1 0.5 10; sys2=tf(num2,den); 13 step(sys2,t); num3=1 0.5 0; sys3=tf(
32、num3,den); step(sys3,t); num4=0 1 0; sys4=tf(num4,den); step(sys4,t);grid 5 k(s,1)G(s),已知 2s(0.1s,1)令k,1作Bode图,应用频域稳定判据确定系统的稳定性,并确定使系统获得最大相位裕度的增益k值。 G=tf(1 1,0.1 1 0 0 ); figure(1) margin(G);grid 14 实验五 控制系统现代分析 1 (2)Bode 图法判断系统稳定性: 已知两个单位负反馈系统的开环传递函数分别为: 用 Bode 图法判断系统闭环的稳定性。 G1=tf(2.7,1 5 4 0 ); fi
33、gure(1) margin(G);grid G2=tf(2.7,1 5 -4 0 ); figure(2) margin(G2);grid 15 2 系统能控性、能观性分析 已知连续系统的传递函数模型: 16 当分别取,1,0,1 时,判别系统的能控性及能观性。 当取-1时: num=1 -1; den=1 10 27 18; G=tf(num,den); G1=ss(G) a=-10 -3.375 -2.25; 8 0 0;0 1 0; b=0.5;0;0; Uc=b,a*b,a2*b; rank(Uc) a = x1 x2 x3 x1 -10 -3.375 -2.25 x2 8 0 0
34、x3 0 1 0 b = u1 x1 0.5 x2 0 x3 0 c = x1 x2 x3 y1 0 0.25 -0.25 d = u1 y1 0 Continuous-time model. rankUc = 3 rankUo = 3 由此,可以得到系统能控性矩阵Uc的秩是3,等于系统的维数,故系统是能控的。能观性矩阵Uo的秩是3,等于系统的维数,故系统能观测的。 当取0时: 17 a = x1 x2 x3 x1 -10 -3.375 -2.25 x2 8 0 0 x3 0 1 0 b = u1 x1 0.25 x2 0 x3 0 c = x1 x2 x3 y1 0 0.5 0 d = u1
35、 y1 0 Continuous-time model. rankUc = 3 rankUo = 3 由此,可以得到系统能控性矩阵Uc的秩是3,等于系统的维数,故系统是能控的。能观性矩阵Uo的秩是3,等于系统的维数,故系统能观测的。 当取1时: a = x1 x2 x3 x1 -10 -3.375 -2.25 x2 8 0 0 x3 0 1 0 b = u1 x1 0.5 x2 0 x3 0 c = x1 x2 x3 18 y1 0 0.25 0.25 d = u1 y1 0 rankUc = 3 rankUo = 2 由此,可以得到系统能控性矩阵Uc的秩是3,等于系统的维数,故系统是能控的。
36、能观性矩阵Uo的秩是2,小于系统的维数,故系统不能观测的。 实验六 PID控制器的设计 31(已知三阶对象模型,利用MATLAB编写程序,研究闭环系统在不同控Gss()1/(1),,制情况下的阶跃响应,并分析结果。 (1) TT,0时,在不同K值下,闭环系统的阶跃响应; Pids=tf('s'); G=1/(s+1)3; for K=0:0.5:2;hold on step(feedback(G*K,1) end 19 比例环节:成比例地反映控制系统的偏差信号e( t) , 偏差一旦产生, 控制器立即产生控制作用,以减小偏差。比例系数越大,误差越小。 TKT,10,(2) 时,
37、在不同值下,闭环系统的阶跃响应; ipds=tf('s'); G=1/(s+1)3; for Ti=1:0.5:3;hold on G1=1+tf(1,Ti,0); step(feedback(G*G1,1) end 20 积分环节:主要用于消除静差,提高系统的无差度。积分作用的强弱取决于积分时间常数TI , TI越大,积分作用越弱,反之则越强。 TKT,1(3) 时,在不同值下,闭环系统的阶跃响应; dpis=tf('s'); G=1/(s+1)3; for Td=1:0.5:3;hold on G1=1+tf(1,1,0)+tf(Td 0,Td/10 1);
38、 step(feedback(G*G1,1) end 21 微分环节:反映偏差信号的变化趋势(变化速率) ,并能在偏差信号变得太大之前, 在系统中引入一个有效的早期修正信号, 从而加快系统的动作速度,减少调节时间。 2(被控对象同上,选择合适的参数进行模拟PID控制(PID参数整定) s=tf('s'); G=1/(s+1)3; K1,L1,T1,G1=getfolpd(1,G);G1 N=10;K=1.014;T=2.101;L=1.1;a=K*L/T; Kp=1.2/a,Ti=2*L,Td=0.5*L,G2=Kp*(1+tf(1,Ti,0)+tf(Td 0,Td/N 1);
39、 step(sys1=feedback(G*G2,1);grid hold on step(feedback(G,1) 22 实验七 系统状态空间设计 3(已知对象模型 ,03010052.,,,xtxtut().()(),,10100, ,15890054.,yx,123,(1) 如果我们想将闭环系统的极点配置到-1,-2,-3,利用MATLAB设计控制器,并绘出闭环系统的阶跃响应曲线。(说明:用两种方法配置极点) 采用Ackermann公式计算: A=-0.3 0.1 -0.05;1 0.1 0;-1.5 -8.9 -0.05; B=2;0;4; C=1 2 3; D=0; P=-1 -2 -3; k=a
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 信息检索语言与技巧考核试卷
- 化工生产过程中的能量集成考核试卷
- 小学生音乐律动课件视频
- 办公文具创新设计理念与实践考核试卷
- 城市绿化管理的城市设计与城市规划考核试卷
- 秋季安全宣传课件图片
- 门市仓库出租合同范本
- 医药器械采购合同范本
- 种植基地配送合同范本
- 酒店客房预订操作规范及流程制度
- 《交通工程CAD》课程教学大纲(本科)
- JJF 1341-2012 钢筋锈蚀测量仪校准规范-(高清现行)
- 换班申请表(标准模版)
- 偏瘫临床路径流程
- 者阴村战友纪念者阴山对越自卫还击作战30周年联谊会计划2
- GB-T 9251-2022 气瓶水压试验方法(高清版)
- 基于单片机的电子广告牌设计毕业设计论文
- 承插型盘扣式支模架专项施工方案
- 我国古代职业教育的发展
- 通用横版企业报价单模板
- 中国移动B-BOSS系统总体结构
评论
0/150
提交评论