MATLAB练习题和答案

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

控制系统仿真实验Matlab部分实验结果目录实验一MATLAB基本操作.........................................................................................................1实验二Matlab编程..................................................................................................................5实验三Matlab底层图形控制......................................................................................................6实验四控制系统古典分析.........................................................................................................12实验五控制系统现代分析...........................................................................................................15实验六PID控制器的设计.......................................................................................................19实验七系统状态空间设计.........................................................................................................23实验九直流双闭环调速系统仿真.............................................................................................251实验一MATLAB基本操作1用MATLAB可以识别的格式输入下面两个矩阵12332357135732391894A144367823355422675342189543iiBi再求出它们的乘积矩阵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);whosNameSizeBytesClassAttributesA5x4160doubleB4x6384doublecomplexC5x6480doublecomplexD2x396doublecomplex2选择合适的步距绘制出下面的图形1sin(/)t,其中11(,)tt=[-1:0.1:1];y=sin(1./t);plot(t,y)23对下面给出的各个矩阵求取矩阵的行列式、秩、特征多项式、范数、特征根、特征向量和逆矩阵。75350083341009103150037193......A,5765710876810957910B12345678910111213141516C,33245518118575131D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,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);3norm(B);norm(C);norm(D);[v,d]=eig(A,'nobalance');[v,d]=eig(B,'nobalance');[v,d]=eig(C,'nobalance');[v,d]=eig(D,'nobalance');m=inv(A);n=inv(B);p=inv(C);q=inv(D);4求解下面的线性代数方程,并验证得出的解真正满足原方程。(a)72124915327221151132130X,(b)1321390721264915321172211521X(a)A=[7,2,1,-2;9,15,3,-2;-2,-2,11,5;1,3,2,13];B=[4;7;-1;0];X=A\B;C=A*X;(b)A=[1,3,2,13;7,2,1,-2;9,15,3,-2;-2,-2,11,5];B=[9,0;6,4;11,7;-2,-1];X=A\B;C=A*X;5.(1)初始化一10*10矩阵,其元素均为1ones(10,10);(2)初始化一10*10矩阵,其元素均为0zeros(10,10);(3)初始化一10*10对角矩阵v=[1:10];diag(v);(4)输入A=[715;256;315],B=[111;222;333],执行下列命令,理解其含义A(2,3)表示取A矩阵第2行、第3列的元素;4A(:,2)表示取A矩阵的第2列全部元素;A(3,:)表示取A矩阵第3行的全部元素;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点乘矩阵BA^2矩阵A的平方A.^2矩阵表示求矩阵A的每一个元素的平方值B/A表示方程AX=B的解XB./A表示矩阵B的每一个元素点除矩阵A的元素6在同一坐标系中绘制余弦曲线y=cos(t-0.25)和正弦曲线y=sin(t-0.5),t∈[0,2π],用不同颜色,不同线的类型予以表示,注意坐标轴的比例控制。t=[0:0.01:2*pi];y1=cos(t-0.25);plot(t,y1,'r--')holdony2=sin(t-0.5);plot(t,y2,'k')5实验二Matlab编程1分别用for和while循环结构编写程序,求出6323626302122222iiK并考虑一种避免循环的简洁方法来进行求和。(a)j=1;n=0;sum=1;forn=n+1:63fori=1:nj=j*2;endsum=sum+j;j=1;endsum(b)j=1;n=1;sum=1;whilen~=64i=1;whilein+1j=j*2;i=i+1;endn=n+1;sum=sum+j;j=1;endSum(c)i=0:63;k=sum(2.^i);2计算1+2+…+n2000时的最大n值s=0;m=0;while(s=2000),m=m+1;s=s+m;end,m3用MATLAB语言实现下面的分段函数,()/,,hxDyfxhDxxDhxD存放于文件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*(xD);6plot(x,y);gridonf1=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在MATLAB命令行中键入h=get(0),查看根屏幕的属性,h此时为根屏幕句柄的符号表示,0为根屏幕对应的标号。h=get(0)h=BeingDeleted:'off'BusyAction:'queue'ButtonDownFcn:''CallbackObject:[]Children:[2x1double]Clipping:'on'CommandWindowSize:[8927]CreateFcn:''CurrentFigure:1DeleteFcn:''Diary:'off'DiaryFile:'diary'Echo:'off'FixedWidthFontName:'CourierNew'Format:'short'FormatSpacing:'loose'HandleVisibility:'on'HitTest:'on'Interruptible:'on'Language:'zh_cn.gbk'MonitorPositions:[111440900]More:'off'7Parent:[]PointerLocation:[1048463]PointerWindow:0RecursionLimit:500ScreenDepth:32ScreenPixelsPerInch:96ScreenSize:[111440900]Selected:'off'SelectionHighlight:'on'ShowHiddenHandles:'off'Tag:''Type:'root'UIContextMenu:[]Units:'pixels'UserData:[]Visible:'on'3h1=get(1);h2=get(10),1,10分别为两图形窗口对应标号,其中1为Matlab自动分配,标号10已在figure(10)中指定。查看h1和h2属性,注意CurrentAxes和CurrenObject属性。h1=get(1)h1=Alphamap:[1x64double]BeingDeleted:'off'BusyAction:'queue'ButtonDownFcn:''Children:170.0012Clipping:'on'CloseRequestFcn:'closereq'Color:[0.80000.80000.8000]Colormap:[64x3double]CreateFcn:''CurrentAxes:170.0012CurrentCharacter:''CurrentObject:[]CurrentPoint:[00]DeleteFcn:''DockControls:'on'FileName:''FixedColors:[10x3double]HandleVisibility:'on'HitTest:'on'IntegerHandle:'on'Interruptible:'on'InvertHardcopy:'on'8KeyPressFcn:''KeyReleaseFcn:''MenuBar:'figure'MinColormap:64Name:''NextPlot:'add'NumberTitle:'on'Pape

1 / 29
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功