数学建模上机练习0815.docx
- 文档编号:14224035
- 上传时间:2023-06-21
- 格式:DOCX
- 页数:13
- 大小:258.42KB
数学建模上机练习0815.docx
《数学建模上机练习0815.docx》由会员分享,可在线阅读,更多相关《数学建模上机练习0815.docx(13页珍藏版)》请在冰点文库上搜索。
数学建模上机练习0815
练习1基础练习
一、矩阵及数组操作:
1.利用基本矩阵产生3×3和15×8的单位矩阵、全1矩阵、全0矩阵、均匀分布随机矩阵([-1,1]之间)、正态分布矩阵(均值为1,方差为4)。
-
2.利用fix及rand函数生成[0,10]上的均匀分布的10×10的整数随机矩阵a,然后统计a中大于等于5的元素个数。
3.在给定的矩阵中删除含有整行内容全为0的行,删除整列内容全为0的列。
二、绘图:
`
4.在同一图形窗口画出下列两条曲线图像:
y1=2x+5;y2=x^2-3x+1,
并且用legend标注。
5.画出下列函数的曲面及等高线:
z=x^2+y^2+sin(by).
三、程序设计:
6.编写程序计算(x在[-3,3],间隔0.01)
7.有一列分数序列:
求前15项的和。
8.用至少三种方法编写函数实现求任意整数n的阶乘。
9.将任意大于6的偶数m写成两个素数p1、p2的和(试着写出所有的m=p1+p2的可能形式)。
10.是否任意3的倍数m可以写成两个素数p1、p2、p3的和(试着写出所有的m=p1+p2+p3
的可能形式)?
四、数据处理与拟合初步:
11.通过测量得到一组数据:
t
1
2
3
4
5
6
7
8
9
10
y
4.842
4.362
3.754
3.368
3.169
3.038
3.034
3.016
3.012
3.005
分别采用y=c1+c2e^(-t)和y=d1+d2te^(-t)进行拟合,并画出拟合曲线进行对比。
t=1:
10;
y=[4.8424.3623.7543.3683.1693.0383.0343.0163.0123.005];
p=polyfit(exp(-t),y,1)
p=
5.21653.1564
xt=1:
0.5:
10;
yt=polyval(p,exp(-xt))
yt=
Columns1through7
5.07554.32043.86243.58463.41613.31393.2520
Columns8through14
3.21443.19163.17773.16943.16433.16123.1593
Columns15through19
3.15823.15753.15713.15683.1567
subplot(1,2,1)
plot(t,y,'r*',xt,yt,'go’)
p1=polyfit(t.*exp(-t),y,1)
p1=
5.02732.9973
t1=1:
0.5;10;
y2=polyval(p1,t1.*exp(-t1))
y2=
Emptymatrix:
1-by-0
subplot(1,2,2)
plot(t,y,'r*',t1,y2,'go')
12.计算下列定积分:
(1)t1=0:
0.01:
2;
z1=exp(-2*t);
trapz(t1,z1)
ans=
0.4909
(2)t2=0:
0.01:
2;
z2=exp(2*t);
trapz(t2,z2)
ans=
26.8000
(3)x=-1:
0.01:
1;
z3=x.^2-3.*x+0.5;
trapz(x,z3)
ans=
1.6667
13.微分方程组
当t=0时,x1(0)=1,x2(0)=-0.5,求微分方程t在[0,25]上的解,并画出相空间轨道图像。
t=0:
25;
[x1,x2]=dsolve('Dx1=0.5-x1','Dx2=x1-4*x2','x1(0)=1','x2(0)=-0.5','t')
x1=1/2+1/2*exp(-t)
x2=1/8+1/6*exp(-t)-19/24*exp(-4*t)
14.设通过测量得到时间t与变量y的数据:
t=[00.30.81.11.62.3];
y=[0.50.821.141.251.351.41];
分别采用多项式:
y=a0+a1t+a2t2
和指数函数 y=b0+b1e^t+b2te^t
进行拟合,并计算均方误差、画出拟合效果图进行比较。
t=[00.30.81.11.62.3];
y=[0.50.821.141.251.351.41];
>>p1=polyfit(t,y,2)
p1=
-0.23460.91340.5326
t1=1:
0.01:
2.3;
y1=polyval(p1,t1)
y1=
Columns1through7
1.21131.21571.22011.22441.22871.23291.2371
Columns8through14
1.24131.24531.24941.25341.25731.26121.2651
Columns15through21
1.26891.27271.27641.28001.28371.28721.2908
Columns22through28
1.29421.29771.30101.30441.30771.31091.3141
Columns29through35
1.31731.32041.32341.32641.32941.33231.3352
Columns36through42
1.33801.34081.34351.34621.34881.35141.3540
Columns43through49
1.35641.35891.36131.36361.36601.36821.3704
Columns50through56
1.37261.37471.37681.37881.38081.38271.3846
Columns57through63
1.38641.38821.39001.39171.39331.39491.3965
Columns64through70
1.39801.39941.40081.40221.40351.40481.4060
Columns71through77
1.40721.40831.40941.41051.41151.41241.4133
Columns78through84
1.41421.41501.41571.41641.41711.41771.4183
Columns85through91
1.41881.41931.41971.42011.42041.42071.4209
Columns92through98
1..42111.42131.42141.42141.42141.42141.4213
Columns99through105
1.42121.42101.42081.42051.42021.41981.4194
Columns106through112
1.41891.41841.41791.41731.41661.41591.4152
Columns113through119
1.41441.41351.41271.41171.41071.40971.4086
Columns120through126
1.40751.40641.40511.40391.40261.40121.3998
Columns127through131
1.39841.39691.39531.39371.3921
z1=polyval(p1,t)
z1=
Columns1through4
0.53260.78551.11311.2534
Columns5through6
1.39331.3921
wucha1=sqrt(sum((z1-y).^2))
wucha1=
0.0720
subplot(1,2,1);
plot(t,y,'r*',t1,y1,'go')
t=[00.30.81.11.62.3];
y=[0.50.821.141.251.351.41];
p2=polyfit(exp(t),y,2)
p2=
-0.02500.35590.3304
t1=1:
0.01:
2.3;
y2=polyval(p2,exp(t1))
y2=
Columns1through6
1.11311.11901.12511.13111.13711.1432
Columns7through12
1.14931.15541.16161.16771.17391.1801
Columns13through18
1.18631.19251.19871.20501.21121.2175
Columns19through24
1.22381.23001.23631.24261.24901.2553
Columns25through30
1.26161.26791.27421.28061.28691.2932
Columns31through36
1.29961.30591.31221.31851.32481.3311
Columns37through42
1.33741.34361.34991.35611.36231.3685
Columns43through48
1.37471.38081.38701.39311.39911.4052
Columns49through54
1.41121.41711.42301.42891.43471.4405
Columns55through60
1.44631.45201.45761.46321.46871.4741
Columns61through66
1.47951.48491.49011.49531.50041.5054
Columns67through72
1.51031.51511.51991.52451.52901.5335
Columns73through78
1.53781.54201.54611.55011.55391.5577
Columns79through84
1.56121.56471.56801.57111.57411.5769
Columns85through90
1.57961.58211.58441.58651.58841.5902
Columns91through96
1.59171.59301.59411.59501.59571.5961
Columns97through102
1.59621.59621.59581.59521.59431.5932
Columns103through108
1.59171.59001.58791.58551.58281.5797
Columns109through114
1.57631.57261.56851.56401.55911.5538
Columns115through120
1.54811.54201.53551.52851.52111.5131
Columns121through126
1.50481.49591.48651.47661.46611.4551
Columns127through131
1.44361.43141.41871.40531.3914
z2=polyval(p2,t)
z2=
0.33040.43490.59910.69170.83581.0167
wucha2=sqrt(sum((z2-y).^2))
wucha2=
1.0956
subplot(1,2,2);
plot(t,y,'r*',t1,y2,'go')
15.观察函数:
y=e^x-1.5cos(2*pi*x)
在区间[-1,1]上的函数图像,完成下列两题:
(1)用函数zero求解上述函数在[-1,1]的所有根,验证你的结果;
(2)用函数finned求解上述函数在[-1,1]上的极小、极大、最小和最大值,在函数图像
上标出你求得的最小值点作出验证。
注:
可以用helpzero命令查看zero的调用格式,zero典型的调用方法是:
zero(@myfun,x0)%返回函数myfun在x0附近的根;
finned典型的调用方法是:
finned(@myfun,x1,x2)%返回函数myfun在区间[x1,x2]上的最小值。
练习2气象观察站调整问题
某地区内有12个气象观察站(位置如图),现有10年各观察站的年降水量数据.为了节省开支,想要适当减少气象站.
问题:
减少哪些观察站可以使得到的降水量的信息量仍然足够大?
试结合方差分析和回归分析方法确定最终保留的观察站。
提示:
注:
以上所有作业均要求编写M文件,目的在于熟悉常用建模方法的使用和相关的Matlab语言。
。
;[
练习3中国总人口的灰色动态预测
运用灰色系统理论及其建模原理,预测2020年和2050年中国人口。
灰色预测法原理可参考:
灰色预测法.ppt
注:
以上所有作业均要求编写M文件,目的在于熟悉常用建模方法的使用和相关的Matlab语言。
练习4优化问题练习
1、线性规划
规划问题不等式约束默认是
,所有不等式约束都要变成
的形式。
函数原型:
X=leapfrog(f,A,b,Aeq,beq,LB,UB,X0,OPTIONS)
f:
目标函数的系数列向量
A:
不等式约束条件的系数矩阵
b:
不等式约束条件的
Age:
等式约束条件的系数矩阵
be:
等式约束条件的
lb:
未知数的下界
up:
未知数的上界
x0:
初值
option:
选项
例:
求解如下规划问题
2、二次规划
函数原型:
X=quadroon(H,f,A,b,Aeq,beq,LB,UB,X0,OPTIONS)
将目标函数写成如下形式:
例:
求解如下规划问题
3、0-1规划
函数原型:
X=binturong(f,A,b,Aeq,beq,X0,OPTIONS)
例:
求解如下规划问题
4、有约束的最值问题
函数原型:
X=fimincon(FUN,X0,A,B,Aeq,Beq,LB,UB,NONLCON,OPTIONS)
fun:
目标函数
noncom:
非线性约束条件函数
例1:
例2:
目标函数:
约束条件:
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数学 建模 上机 练习 0815