还剩5页未读,继续阅读
文本内容:
控制系统仿真MATLAB实验指导书青岛大学自动化工程学院年月20064
一、实验目的
1.Be familiarwith MATLABEnvironment
2.Be familiarwith arrayand matrix
3.Be familiarwith MATLABoperations andsimple plotfunction
二、实验内容
1.Be familiarwith Matlab
6.5Startup Matlab
6.5,browse themajor toolsof theMatlab desktop■The CommandWindows■The CommandHistory Windows■Launch Pad■The Edit/Debug Window■Figure Windows■Workspace Browserand ArrayEditer■Help Browser■Current DirectoryBrowser
1.
10.
02.1-
3.
56.
00.
01.1-
6.
62.
83.4array}-
0.3-
0.
41.3—
1.
40.
01.
10.0_
2.Give theanswer of the followingquestions forthe array1What isthe sizeof array12What isthe value of array14,13What isthe sizeand valueof array1:,1:24What isthe sizeand valueof array1
[13],end
3.Give theanswer ofthe followingcommadla=l:2:5;2b=0a9a5];3c=bl:2:3,1:2:3;4d=a+b2,:5w=[zerosl,3ones3,l93:
514.Give theanswer ofthe sub-arrays
1.
10.
00.
01.1-
6.
62.
83.4array}=
2.
10.
10.3-
0.
41.3-
1.
45.
10.
01.
10.01array13,:;2array1:,3;3array11:2:3,
[334]4arrayl[l1],:
5.Give theanswer ofthe followingoperations2-21r i-ii rii,b=,c-,d=eye2-12j L02J2_la+b2a*d3a.*d4a*c5a.*c6a\b7a.\b8a.Ab
6.Solve the following systemof simultaneousequations forx—
2.0X1+
5.0+
1.03+3・014+
4.0/-
1.0x—
0.0X2尤
62.Ox,-
1.0x-
5.0-
2.0+
6.0x+
4.0x=
1.0X X23456—
1.0X1+
6.0^2—
4.0%3—
5.0%+
3.0/1・04=—
6.04一—
4.0%]+3・
6.0—
5.0%4—
2.0%5—
2.0%6=
10.00%2-兄3—
3.0%+
6.0x+
4.0+
2.0%4—
6.04・04=—
6.0元3天+
2.0%+
4.0%2+
4.0+
4.0+
5.0/
4.0x=~
2.0工3工4一
67.EditRun them-file%test stepresponse functionwn=6;kosi=[
0.1:
0.1:
1.02];figurel;hold onfor kos=kosinum=wnA2;den=[l,2*kos*wn,wn.A2];stepnum,den endhold off;
8.EditRun them-file%test plotfunction x=0:pi/20:3*pi;yl=sinx;y2=2*cos2*x;plotx,yl/rv:\x,y2/bo—1;titlePlot theLine ofy=sin2x andits derivative;xlabelfX axis1;ylabel!Y axis;legend*fxVd/dx fx,;grid on;
9.EditRun them-file%test subplotand loglogfunction x=0:
0.1:10;y=x.A2-l
0.*x+26;subplot2,2,l;plotx,y;grid on;;subplot2,2,2;semilogxx,y;grid on;subplot2,2,3semilogyx,y;grid on;subplot2,2,4;loglogx,y;grid on;
10.EditRun them-file%test maxand plotfunctionvolts=120;rs=50;rl=l:
0.1:100;amps=volts./rs+rl;pl=amps.A
2.*rl;[maxvol,index]=maxpl;plotrl,pl,rlindex,plindex,,rh,;grid on;
一、实验目的
1.Learn todesign branchand loopstatements program
2.Be familiarwith relationaland logicaloperators
3.Practice2D plotting
二、实验内容选择练习,不需提交实验报告PART I:
1.Hold commandexercise x=-pi:pi/20:pi;yl=sinx;y2=cosx;plotx,yl,,b,;hold on;plotx,y2,k--;holdoff;legend sinx,‘cosx
2.Figure commandexercise figurel;subplot2,l,l;x-pi:pi/20:pi;y=sinx;plotx,y;grsid on;titleC^ubplot1Title1;subplot2,l,2;x-pi:pi/20:pi;y=cosx;plotx,y;grid on;titleC^ubplot2Title1;
3.Polar Plotsexerciseg=
0.5;theta=0:pi/20:2*pi;gain=2*g*1+costheta;polartheta,gain,r-f;title\fontsize{20}\bfGain versusangle\theta1;
4.Compare the3approaches followsLoops andVectorization%A.Perform calculationby ForLoop withpre-initialize arraytic;square=zerosl,l0000%pre-initialize arrayfor ii=l:10000squareii=iiA2;square_rootii=ii A1/2;cube_rootii=iiAl/3;endtoe;tl=toc%B.Perform calculationby ForLoop withoutpre-initialize arraytic;for ii=1:10000squareii=iiA2;square_rootii=ii A1/2;cube_rootii=iiAl/3;endtoe;t2=toc%C.Perform calculationwith vectorstic;ii=1:10000squareii=ii.A2;square_rootii=ii.A1/2;cube_rootii=ii.Al/3;endtoe;t3=toc需提交实验报告PART II:
1.Assume thata,b,c,and dare defined,and evaluatethefollowingexpression.a=20;b=-2;c=0;d=l;1ab;2bd;3abcd;4a==b;5abc;6〜〜b;a=2;b=[l-2;-010];c=[01;20];d=[-212;010];7〜a b8acbc9c=d〉a=2;b=3;c=10;d=0;10a*b2a*c11d|ba12d|ba八〉a=20;b=-2;c=0;d=9Tesf;13isinfa/b14isinfa/c15abischard16isemptyc
2.Write aMatlab programto solvethe functionyx=In---,where x is anumber
1.Use anif\-xstructure toverify thatthe valuepassed tothe programis legal.If thevalueofxislegal,caculateyx.If not,write asuitable errormessage andquit.
3.Write outm.file andplot thefigures withgridsAssume thatthe complexfunction ftis definedby theequationft=
0.5-
0.25it-
1.0Plot theamplitude andphase offunction for0f
4.
4.Write theMatlab statementsrequired tocalculate ytfrom theequation1—3/2+5/NOM=/ofor valueoftbetween-9and9in stepsof
0.
5.Use loopsand branchesto performthis calculation.
5.Write anm.file toevalue theequation yx=x2-3x+2for allvalues ofx between
0.1and3,in stepsof
0.
1.Do thistwice,once witha forloop andonce withvectors.Plot theresulting。