1、12343324,,,56785518,, C,D,910111211857,131415165131,,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
2、=poly(D);norm(A);2 norm(B);norm(C);norm(D);v,d=eig(A,nobalance);v,d=eig(B,v,d=eig(C,v,d=eig(D,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)
3、 A=1,3,2,13;7,2,1,-2;-2,-2,11,5;B=9,0;6,4;11,7;-2,-1;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矩阵第,行的全部元素;,1:2:3)表
4、示取A矩阵第1、3列的全部元素;,3).*B(:,2)表示A矩阵第3列的元素点乘B矩阵第2列的元素 ,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=cos(t-0.25);plot(t,y1,r-) ho
5、ld on y2=sin(t-0.5);plot(t,y2,k4 实验二 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;sum (b)j=1;n=1;while n=64 i=1;while in+1 i=i+1;n=n+1;Sum (c)i=0:63;k=sum(2.i);2计算 1+2+n2000 时的最大 n 值 s=0;m=0;while(s=200
6、0),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)&(xD);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);pl
7、ot(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: offBusyAction:queueButtonDownFcn:CallbackObject: Children: 2x1 double Clipping:onCommandWindowSize: 89 27 CreateFcn:CurrentFigure: 1 D
8、eleteFcn:Diary:DiaryFile:diaryEcho:FixedWidthFontName:Courier NewFormat:shortFormatSpacing:looseHandleVisibility:HitTest:Interruptible:Language:zh_cn.gbkMonitorPositions: 1 1 1440 900 More:6 Parent:PointerLocation: 1048 463 PointerWindow: 0 RecursionLimit: 500 ScreenDepth: 32 ScreenPixelsPerInch: 96
9、 ScreenSize:Selected:SelectionHighlight:ShowHiddenHandles:Tag:Type:rootUIContextMenu:Units:pixelsUserData:Visible: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 170.0012 CloseRequestFcn:closere
10、qColor: 0.8000 0.8000 0.8000 Colormap: 64x3 double CurrentAxes:CurrentCharacter:CurrentObject:CurrentPoint: 0 0 DockControls:FileName:FixedColors: 10x3 double IntegerHandle:InvertHardcopy:7 KeyPressFcn:KeyReleaseFcn:MenuBar:figureMinColormap: 64 Name:NextPlot:addNumberTitle:PaperOrientation:portrait
11、PaperPosition: 0.6345 6.3452 20.3046 15.2284 PaperPositionMode:manualPaperSize: 20.9840 29.6774 PaperType:A4PaperUnits:centimetersPointer:arrowPointerShapeCData: 16x16 double PointerShapeHotSpot: 1 1 Position: 440 378 560 420 Renderer:paintersRendererMode:autoResize:ResizeFcn:SelectionType:normalToo
12、lBar:WindowButtonDownFcn:WindowButtonMotionFcn:WindowButtonUpFcn:WindowKeyPressFcn:WindowKeyReleaseFcn:WindowScrollWheelFcn:WindowStyle:WVisual:00 (RGB 32 GDI, Bitmap, Window)WVisualMode: h2=get(10) h2 = 8 342.0011 9 4 输入h.Children,观察结果。 h.Children ans = 10 5 键入gcf,得到当前图像句柄的值,分析其结果与h,h1,h2中哪个一致,为什么?
13、 ans = 结果与h的一致 6 鼠标点击Figure 1窗口,让其位于前端,在命令行中键入gcf,观察此时的值,和上一步中有何不同,为什么?7 观察h1.Children和h2.Children,gca的值。 h1.Children 170.0012 h2.Children 342.0011 gca 8 观察以下程序结果h3=h1.Children; set(h3,Color,greenh3_1=get(h3,childrenset(h3_1, red 其中h3_1为Figure1中线对象句柄,不能直接采用h3_1=h3.Children命令获得。9 命令行中键入plot(t,sin(t-p
14、i/3),观察曲线出现在哪个窗口。h4=h2.Children;axes(h4);plot(t,sin(t-pi/3),看看此时曲线显示在何窗口。plot(t,sin(t-pi/3)后,曲线出现在figure1窗口; 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:3;figure(1) step(sys,t);grid 修改
15、参数,实现和的阶跃响应; ,1,2时: ,1a=sqrt(10);zeta=1;grid ,2zeta=2;1,2,10修改参数,实现和的阶跃响应() n1nn2nn21,时: n1n212 num=0.25;den=1 2*zeta*0.5*a 0.25; sys=tf(num,den); ,2,n2nnum=40;den=1 2*zeta*2*a 40;(2) 试做出以下系统的阶跃响应,并比较与原系统响应曲线的差别与特点,作出相应的实验分析结果。222s,10s,0.5s,10s,0.5sG(s),G(s),G(s), ; 123222s,2s,10s,2s,10s,2s,10sG(s), 22s,2s,10要求:分析系统的阻尼比和无阻尼振荡频率对系统阶跃响应的影响;分析响应曲线的零初值、非零初值与系统模型的关系;分析响应曲线的稳态值与系统模型的关系;分析系统零点对阶跃响应的影响;num1=0 2 10;sys1=tf(num1,den);step(sys1,t);num2=1 0.5 10;sys2=tf(n
copyright@ 2008-2023 冰点文库 网站版权所有
经营许可证编号:鄂ICP备19020893号-2