数学建模实验三.docx
《数学建模实验三.docx》由会员分享,可在线阅读,更多相关《数学建模实验三.docx(10页珍藏版)》请在冰豆网上搜索。
数学建模实验三
实验3实验报告
2013326601054夏海浜13信科1班
完成教材(2013高教版)实验;
1、P190题目1、2;
1、
x=[0.1,0.8,1.3,1.9,2.5,3.1];
y=[1.2,1.6,2.7,2.0,1.3,0.5];
y2=interp1(x,y,2.0,'linear')
y2=interp1(x,y,2.0,'cubic')
y2=
1.8833
y2=
1.8844
x=0:
4;
y=0:
4;
2、
z=[4,0,-4,0,4
3,2,-2,2,3
2,1,0,1,2
3,2,-2,2,3
4,0,-4,0,4];
subplot(1,2,1)
mesh(x,y,z)
x1=0:
0.1:
4;
y1=0:
0.1:
4;
[x2,y2]=meshgrid(x1,y1);
z1=interp2(x,y,z,x2,y2,'cubic');
subplot(1,2,2)
mesh(x1,y1,z1);
2、P194题目1、2;
1、
x=[1.2,1.8,2.1,2.4,2.6,3.0,3.3];
y=[4.85,5.2,5.6,6.2,6.5,7.0,7.5];
p4=polyfit(x,y,4)
p5=polyfit(x,y,5)
p6=polyfit(x,y,6)
x1=1.2:
0.05:
3.3;
y1=polyval(p4,x1);
y2=polyval(p5,x1);
y3=polyval(p6,x1);
plot(x,y,'*r',x1,y1,'-b',x1,y2,'-b',x1,y3,'-b')
p4=
0.4161-4.139015.0681-22.210116.0963
p5=
0.8825-9.853842.4484-87.564887.1388-28.7370
p6=
-2.010729.0005-170.6763523.2180-878.3092763.9307-263.4667
p4=
0.4161-4.139015.0681-22.210116.0963
p5=
0.8825-9.853842.4484-87.564887.1388-28.7370
p6=
-2.010729.0005-170.6763523.2180-878.3092763.9307-263.4667
2、
fun=inline('c
(1)*exp(-c
(2)*(t-c(3)).^2)','c','t');
t=0:
1:
24;
T=[15,14,14,14,14,15,16,18,20,22,23,25,28,31,32,31,29,27,25,24,22,20,18,17,16];
c=lsqcurvefit(fun,[0,0,0],t,T)
norm(feval(fun,c,t)-T)^2
p2=polyfit(t,T,2);
p3=polyfit(t,T,3);
p4=polyfit(t,T,4);
t1=0:
0.1:
24;
y1=polyval(c,t1)
y2=polyval(p2,t1);
y3=polyval(p3,t1);
y4=polyval(p4,t1);
plot(t,T,'*r',t1,y2,'-b',t1,y3,'-b',t1,y4,'-b',t,feval(fun,c,t),'-b')
>>Untitled3
Solverstoppedprematurely.
lsqcurvefitstoppedbecauseitexceededthefunctionevaluationlimit,
options.MaxFunEvals=300(thedefaultvalue).
c=
2.2181-0.0000-436.6246
ans=
749.8210
y1=
Columns1through10
-436.6246-436.6024-436.5358-436.4249-436.2697-436.0700-435.8261-435.5377-435.2050-434.8279
Columns11through20
-434.4065-433.9407-433.4305-432.8760-432.2771-431.6339-430.9463-430.2143-429.4380-428.6173
Columns21through30
-427.7522-426.8428-425.8890-424.8909-423.8484-422.7615-421.6303-420.4547-419.2348-417.9705
Columns31through40
-416.6618-415.3088-413.9114-412.4696-410.9835-409.4530-407.8782-406.2590-404.5954-402.8875
Columns41through50
-401.1352-399.3385-397.4975-395.6121-393.6824-391.7083-389.6898-387.6270-385.5198-383.3683
Columns51through60
-381.1724-378.9321-376.6475-374.3185-371.9451-369.5274-367.0653-364.5589-362.0081-359.4129
Columns61through70
-356.7734-354.0895-351.3613-348.5887-345.7717-342.9104-340.0047-337.0546-334.0602-331.0214
Columns71through80
-327.9383-324.8108-321.6389-318.4227-315.1621-311.8571-308.5078-305.1141-301.6761-298.1937
Columns81through90
-294.6669-291.0958-287.4803-283.8205-280.1163-276.3677-272.5748-268.7375-264.8558-260.9298
Columns91through100
-256.9594-252.9447-248.8856-244.7821-240.6343-236.4421-232.2056-227.9247-223.5994-219.2297
Columns101through110
-214.8157-210.3574-205.8547-201.3076-196.7161-192.0803-187.4002-182.6756-177.9068-173.0935
Columns111through120
-168.2359-163.3339-158.3876-153.3969-148.3618-143.2824-138.1586-132.9905-127.7779-122.5211
Columns121through130
-117.2198-111.8742-106.4843-101.0500-95.5713-90.0483-84.4809-78.8691-73.2130-67.5125
Columns131through140
-61.7676-55.9784-50.1448-44.2669-38.3446-32.3779-26.3669-20.3115-14.2118-8.0677
Columns141through150
-1.87924.353610.630816.952423.318329.728536.183242.682249.225555.8133
Columns151through160
62.445469.121875.842682.607889.417396.2712103.1695110.1121117.0991124.1304
Columns161through170
131.2061138.3262145.4906152.6994159.9525167.2501174.5919181.9782189.4088196.8837
Columns171through180
204.4030211.9667219.5748227.2272234.9239242.6651250.4506258.2804266.1546274.0732
Columns181through190
282.0362290.0435298.0951306.1911314.3315322.5163330.7454339.0189347.3367355.6989
Columns191through200
364.1054372.5564381.0516389.5913398.1753406.8037415.4764424.1935432.9549441.7607
Columns201through210
450.6109459.5055468.4444477.4276486.4552495.5272504.6436513.8043523.0093532.2588
Columns211through220
541.5526550.8907560.2732569.7001579.1714588.6870598.2469607.8512617.4999627.1930
Columns221through230
636.9304646.7122656.5383666.4088676.3237686.2829696.2865706.3344716.4267726.5634
Columns231through240
736.7444746.9698757.2395767.5537777.9121788.3150798.7622809.2537819.7896830.3699
Column241
840.9946
3、P198题目1、2;
1、
(1),
(2),(4);
functiony=f(x)
y=(1/sqrt(2*pi))*exp(-x.*x./2)
>>I=quad(@f,0,1)
y=
5.00005.13585.27165.50005.72845.86426.0000
y=
5.06795.2037
y=
5.38585.6142
y=
5.79635.9321
I=
5.5000
(2)
functiony=g(x)
y=exp(sin(x))
>>I=quad(@f,0,pi/2)
y=
5.00005.21335.42665.78546.14426.35756.5708
y=
5.10665.3199
y=
5.60605.9648
y=
6.25086.4641
I=
9.0877
(4)
functiony=f(x)
y=1/(5+x)
>>I=quad(@f,-1,1)
y=
4.00004.27164.54325.00005.45685.72846.0000
y=
4.13584.4074
y=
4.77165.2284
y=
5.59265.8642
I=
10
2、
f=inline('exp(-(x.^2+y.^2))./(x+y)','x','y');
y=dblquad(f,0,4,1,2)
y=
0.0689