matlab习题第六章.docx
- 文档编号:4042635
- 上传时间:2022-11-27
- 格式:DOCX
- 页数:20
- 大小:18.14KB
matlab习题第六章.docx
《matlab习题第六章.docx》由会员分享,可在线阅读,更多相关《matlab习题第六章.docx(20页珍藏版)》请在冰豆网上搜索。
matlab习题第六章
第六章
实验指导
1、
(1)
>>A=[1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6];
p=[0.95,0.67,0.52]';
x=A\p
x=
1.2000
0.6000
0.6000
(2)、
>>A=[1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6];
p=[0.95,0.67,0.52]';
>>A=[1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6];
p=[0.95,0.67,0.53]';
>>x=A\p
x=
3.0000
-6.6000
6.6000
(3)、
>>A=[1/2,1/3,1/4;1/3,1/4,1/5;1/4,1/5,1/6];
p=[0.95,0.67,0.53]';
x=A\p
cond(A)
x=
3.0000
-6.6000
6.6000
ans=
1.3533e+003
2、
(1)
M文件:
functionfx=funx(x)
fx=x^41+x^3+1;
运行;
>>z=fzero(@funx,-1)
z=
-0.9525
(2)
M文件:
functionfx=funx2(x)
fx=x-sin(x)/x;
运行:
>>x2=fzero(@funx2,0.5)
x2=
0.8767
(3)
M文件:
functionq=fun3(p)
x=p
(1);
y=p
(2);
z=p(3);
q
(1)=sin(x)+y^2+log(z)-7;
q
(2)=3*x+2^y-z^3+1;
q(3)=x+y+z-5;
运行:
>>options=optimset('Display','off');
x=fsolve(@fun3,[1,1,1]',options)
q=fun3(x)
x=
0.5991
2.3959
2.0050
q=
1.0e-010*
0.22130.38040.0009
3、
(1)
M文件:
functionyp=fun4(t,y)
yp=-(1.2+sin(10*t))*y;
运行:
>>t0=0;
tf=5;
y0=1;
[t,y]=ode23(@fun4,[t0,tf],y0);
t'
y'
ans=
Columns1through9
00.06670.13750.20030.26950.35280.43620.50330.5663
Columns10through18
0.63690.69130.74570.80810.87380.95911.02771.09631.1600
Columns19through27
1.22461.30821.37141.43471.50011.58421.65301.72191.7858
Columns28through36
1.85011.93191.99532.05872.12362.20532.27452.34382.4080
Columns37through45
2.47192.55012.61402.67792.74192.81932.90462.96853.0323
Columns46through54
3.09593.17213.23643.30073.36423.43953.53283.59653.6602
Columns55through63
3.72383.79983.86423.92863.99204.06714.14084.21444.2800
Columns64through72
4.34324.41594.48124.54654.60944.68124.75674.83224.8990
Columns73through74
4.96205.0000
ans=
Columns1through9
1.00000.90350.78220.68230.59840.54020.51820.51060.4976
Columns10through18
0.46560.42800.38440.33550.29360.25950.24690.24210.2382
Columns19through27
0.22900.20540.18190.15850.13870.12250.11640.11400.1122
Columns28through36
0.10800.09740.08640.07530.06580.05810.05490.05370.0529
Columns37through45
0.05110.04660.04150.03610.03160.02780.02580.02530.0249
Columns46through54
0.02410.02210.01970.01720.01500.01320.01220.01190.0117
Columns55through63
0.01140.01040.00930.00810.00710.00620.00580.00560.0055
Columns64through72
0.00540.00500.00450.00390.00340.00300.00270.00260.0026
Columns73through74
0.00250.0025
(2)
M文件:
functionyp=fun5(t,y)
yp=cos(t)-y/(1+t^2)
运行:
>>t0=0;
tf=5;
y0=1;
[t,y]=ode23(@fun5,[t0,tf],y0);
t'
y'
yp=
0
yp=
0.0277
yp=
0.0447
yp=
0.0659
yp=
0.0718
yp=
0.0511
yp=
0.0177
yp=
0.0759
yp=
0.0722
yp=
0.0647
yp=
0.0312
yp=
0.0093
yp=
-0.0206
yp=
-0.0943
yp=
-0.1322
yp=
-0.1785
yp=
-0.2916
yp=
-0.3451
yp=
-0.4066
yp=
-0.5736
yp=
-0.6446
yp=
-0.7206
yp=
-0.8439
yp=
-0.8893
yp=
-0.9304
yp=
-0.8021
yp=
-0.8365
yp=
-0.8698
yp=
-0.9247
yp=
-0.9452
yp=
-0.9626
yp=
-0.9811
yp=
-0.9855
yp=
-0.9872
yp=
-0.9763
yp=
-0.9810
yp=
-0.9845
yp=
-0.9872
yp=
-0.9864
yp=
-0.9842
yp=
-0.9750
yp=
-0.9680
yp=
-0.9595
yp=
-0.9312
yp=
-0.9137
yp=
-0.8936
yp=
-0.8373
yp=
-0.8050
yp=
-0.7692
yp=
-0.6766
yp=
-0.6260
yp=
-0.5715
yp=
-0.4352
yp=
-0.3639
yp=
-0.2886
yp=
-0.0993
yp=
-0.0045
yp=
0.0927
yp=
0.2101
yp=
0.2672
yp=
0.3242
ans=
Columns1through9
00.50000.80161.10331.40771.75372.23012.52152.8129
Columns10through18
2.97273.13263.30013.50913.75494.03754.36374.75845.0000
ans=
Columns1through9
1.00001.01461.03631.04501.01620.91570.64510.41220.1437
Columns10through18
-0.0122-0.1699-0.3330-0.5273-0.7327-0.9233-1.0649-1.1040-1.0534
4、M文件
functionfx=mymin(x)
fx=-(1+x^2)/(1+x^4);
运行:
>>x=fminbnd(@mymin,0,2);
-mymin(x)
ans=
1.2071
5、
M文件:
functionf=fun6(x)
f=-(sqrt(x
(1))+(400-x
(1))*1.1+(sqrt(x
(2))+(400-x
(1))*1.1-x
(2))*1.1+sqrt(3)+(((400-x
(1))*1.1-x
(2))*1.1-x(3))*1.1+sqrt(x(x4)));
运行:
options=optimset('Display','off');
[x,fval]=fmincon(@fun6,[0,0,0],[],[],a,b,lb,ub)
-fval
思考练习
1、
(1)
>>A=[2,3,5;3,7,4;1,-7,1];
B=[10,3,5]';
C1=inv(A)*B
C2=A\B
[L,U]=lu(A);
x=U\(L\B)
C1=
-1.8060
-0.5373
3.0448
C2=
-1.8060
-0.5373
3.0448
x=
-1.8060
-0.5373
3.0448
(2)、
>>A=[6,5,-2,5;9,-1,4,-1;3,4,2,-2;3,-9,0,2];
B=[-4,13,1,11]';
C1=inv(A)*B
C2=A\B
[L,U]=lu(A);
x=U\(L\B)
C1=
0.6667
-1.0000
1.5000
0.0000
C2=
0.6667
-1.0000
1.5000
-0.0000
x=
0.6667
-1.0000
1.5000
-0.0000
2、
(1)
M文件;
functionfx=funx1(x)
fx=3*x+sin(x)-exp(x);
运行:
>>x1=fzero(@funx1,1.5)
x1=
1.8900
(2)
M文件:
functionfx=funx2(x)
fx=x-1/x+5;
运行;
>>x1=fzero(@funx2,1)
x1=
0.1926
(3)
M文件:
functionq=fun3(p)
x=p
(1);
y=p
(2);
q
(1)=x^2+y^2-9;
q
(2)=x+y-1;
运行:
>>options=optimset('Display','off');
x=fsolve(@fun3,[3,0]',options)
q=fun3(x)
x=
2.5616
-1.5616
q=
1.0e-013*
0.56840.0044
3、
(1)
M文件:
functionydot=vdpol(t,y);
ydot
(1)=(2-3*y
(2)-2*t*y
(1))./(1+t^2);
ydot
(2)=y
(1);
ydot=ydot';
运行:
>>t0=0;
tf=5;
y0=[0,1];
[t,y]=ode45(@vdpol,[t0,tf],y0);
[t,y]
ans=
001.0000
0.0001-0.00011.0000
0.0001-0.00011.0000
0.0002-0.00021.0000
0.0002-0.00021.0000
0.0005-0.00051.0000
0.0007-0.00071.0000
0.0010-0.00101.0000
0.0012-0.00121.0000
0.0025-0.00251.0000
0.0037-0.00371.0000
0.0050-0.00501.0000
0.0062-0.00621.0000
0.0125-0.01250.9999
0.0188-0.01880.9998
0.0251-0.02500.9997
0.0313-0.03130.9995
0.0627-0.06240.9980
0.0941-0.09290.9956
0.1255-0.12260.9922
0.1569-0.15130.9879
0.2717-0.24390.9650
0.3864-0.31270.9328
0.5011-0.35540.8943
0.6158-0.37380.8523
0.7408-0.37210.8054
0.8658-0.35420.7599
0.9908-0.32630.7173
1.1158-0.29320.6785
1.2408-0.25840.6441
1.3658-0.22400.6139
1.4908-0.19150.5880
1.6158-0.16160.5659
1.7408-0.13450.5475
1.8658-0.11030.5322
1.9908-0.08890.5198
2.1158-0.07020.5099
2.2408-0.05380.5021
2.3658-0.03960.4963
2.4908-0.02730.4921
2.6158-0.01670.4894
2.7408-0.00750.4879
2.86580.00040.4875
2.99080.00710.4880
3.11580.01280.4892
3.24080.01770.4911
3.36580.02180.4936
3.49080.02530.4966
3.61580.02820.4999
3.74080.03060.5036
3.86580.03250.5075
3.99080.03410.5117
4.11580.03540.5160
4.24080.03640.5205
4.36580.03710.5251
4.49080.03760.5298
4.61580.03800.5345
4.71190.03810.5382
4.80790.03820.5418
4.90400.03820.5455
5.00000.03810.5492
(2)
M文件;
functionydot=vdpoll(t,y);
ydot
(1)=cos(t)-y(3)./(3+sin(t))+5*y
(1).*cos(2*t)/((t+1).^2)-y
(2);
ydot
(2)=y
(1);
ydot(3)=y
(2);
ydot=ydot';
运行:
t0=0;
tf=5;
y0=[1;0;2];
[t,y]=ode45(@vdpoll,[t0,tf],y0);
[t,y]
ans=
01.000002.0000
0.00011.00030.00012.0000
0.00011.00050.00012.0000
0.00021.00080.00022.0000
0.00021.00110.00022.0000
0.00051.00240.00052.0000
0.00071.00380.00072.0000
0.00101.00510.00102.0000
0.00121.00640.00122.0000
0.00251.01320.00252.0000
0.00371.01990.00382.0000
0.00501.02670.00502.0000
0.00621.03350.00632.0000
0.01251.06800.01292.0001
0.01881.10300.01972.0002
0.02511.13860.02682.0003
0.03131.17490.03402.0005
0.06271.36470.07392.0022
0.09411.56770.11992.0052
0.12551.78220.17242.0098
0.15692.00580.23192.0161
0.21952.46830.37172.0348
0.28202.93340.54052.0632
0.34453.37640.73792.1030
0.40703.77370.96172.1560
0.53204.34851.47402.3068
0.65704.56362.03462.5252
0.78204.40842.59802.8155
0.90703.94363.12283.1744
1.02113.34073.53963.5553
1.13522.64293.88183.9796
1.24931.90924.14184.4381
1.36341.17894.31764.9215
1.48840.40724.41635.4684
1.6134-0.32774.42106.0218
1.7384-1.02914.33596.5699
1.8634-1.70764.16477.1020
1.9884-2.37803.90947.6075
2.1134-3.05293.57008.0759
2.2384-3.74253.14548.4965
2.3634-4.45232.63358.8586
2.4884-5.18322.03169.1511
2.6134-5.92861.33729.3626
2.7384-6.67470.54939.4815
2.8634-7.3993-0.33079.4961
2.9884-8.0730-1.29849.3953
3.1134-8.6589-2.34529.1683
3.2384-9.1181-3.45788.8061
3.3634-9.4112-4.61798.3018
3.4884-9.5015-5.80247.6508
3.6134-9.3604-6.98376.8516
3.7384-8.9696-8.13185.9062
3.8634-8.3235-9.21544.8210
3.9884-7.4281-10.20263.6063
4.1134-6.3005-11.06302.2758
4.2384-4.9650-11.76890.8471
4.3634-3.4512-12.2965-0.6591
4.4884-1.7921-12.6257-2.2190
4.6134-0.0200-12.7401-3.8067
4.73841.8334-12.6274-5.3945
4.86343.7383-12.2793-6.9536
4.89764.2637-12.1428-7.3705
4.93174.7902-11.9882-7.7825
4.96595.3174-11.8157-8.1888
5.00005.8445-11.6252-8.5890
4、
M文件;
functionfx=mymin(x)
fx=sin(x)+cos(x.^2);
运行:
>>x=fminbnd(@mymin,0,pi);mymin(x)
ans=
-0.0220
5、
M文件:
functionfx=mymax(x);
fx=-(9*x+4*x.^3-12*x.^2);
运行:
>>[x,y1]=fminbnd(@mymax,0,1.5);
-y1
ans=
2.0000
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- matlab 习题 第六