练1 matlab练
矩阵数组操作:
1.利基矩阵产生3×315×8单位矩阵全1矩阵全0矩阵均匀分布机矩阵([11]间)正态分布矩阵(均值1方差4)然正态分布矩阵中1元素变11元素变0
2.利fixrand函数生成[010]均匀分布10×10整数机矩阵a然统计a中等5元素数
3.定矩阵中删含整行容全0行删整列容全0列
4.机生成10阶矩阵求元素值介0~1000间统计元素中奇数数素数数
二绘图:
5.图形窗口画出列两条曲线图求改变线型标记:
y12x+5 y2x^23x+1
legend标注
6.画出列函数曲面等高线:
zsinxcosyexp(sqrt(x^2+y^2)).
7.图形中绘制行三列子图分画出量x[1 5 8 10 12 5 3]三维饼图柱状图条形图
三程序设计:
8.编写程序计算(x[88]间隔05)先新建输保存命令窗口代数
9.两种方法求数列:
前15项
10.编写程序产生20两位机整数输出中均数偶数
11.试找出100素数
12.时
四数处理拟合初步:
13机产生10两位机数行量AA中元素降序排列BB重排A
14.通测量组数:
t
1
2
3
4
5
6
7
8
9
10
y
4842
4362
3754
3368
3169
3038
3034
3016
3012
3005
分采yc1+c2e^(t)yd1+d2te^(t)进行拟合画出散点两条拟合曲线拟合效果
15.计算列定积分:
16.(1)微分方程组
t0时x1(0)1x2(0)05求微分方程t[025]解画出相空间轨道图
(2)求微分方程解
17.设通测量时间t变量y数:
t[0 03 08 11 16 23]
y[05 082 114 125 135 141]
分采二次项式指数函数yb0+b1e^t+b2te^t进行拟合计算均方误差画出拟合效果图进行较
18.观察函数:ye^x15cos(2*pi*x)区间[11]函数图完成列两题:
(1)函数fzero求解述函数[11]根验证结果
(2)函数fminbnd求解述函数[11]极极值函数图标出求值点作出验证
注:help fzero命令查fzero调格式fzero典型调方法:
fzero(@myfunx0) 返回函数myfunx0附根
fminbnd典型调方法:
fminbnd(@myfunx1x2) 返回函数myfun区间[x1x2]值
19.(1)解方程组
(2)解方程组
20.求函数泰勒展开式(x次数超10)
练2 spss(matlab实现兴趣试试)
21.利附件中数结合回分析专题中三例题分进行线性回非线性回 求:
(I)先作相关性分析绘制散点图
(II)做完回分析进行种检验
(1) 写出验回方程
(2) 拟合优度检验
(3) 回方程显著性检验
(4) 回系数显著性检验
(5) 残差图
(6) 残差分析异常值检验
练3 lingo&lindo(matlab实现部分功)
22求解线性规划:满足条件求值值.
23 (整数规划)福安商场中型百货商场售货员需求统计分析表示保证售货员充分休息售货员周工作五天休息两天求休息两天连续问该安排售货员休息满足工作需配备售货员数少请列出问题数学模型
时间
需售货员数
时间
需售货员数
星期
28
星期五
19
星期二
15
星期六
3l
星期三
24
星期日
28
星期四
25
24求解非线性规划
25求解非线性规划
第次练答案
第1题:
(1)3*3
单位阵:xeye(33)
>> xeye(33)
x
1 0 0
0 1 0
0 0 1
全1阵:xones(33)
>> xones(33)
x
1 1 1
1 1 1
1 1 1
全0阵:xzeros(33)
>> xzeros(33)
x
0 0 0
0 0 0
0 0 0
均匀分布机阵([11])间:xunifrnd(1133)
>> xunifrnd(1133)
x
06294 08268 04430
08116 02647 00938
07460 08049 09150
正态分布机阵(均值1标准差0):xnormrnd(1033)
>> xnormrnd(1033)
x
1 1 1
1 1 1
1 1 1
>> x(x<1)0
x(x>1)1
x
1 1 1
1 1 1
1 1 1
(2)15*8
单位阵:xeye(158)
>> xeye(158)
x
1 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0
0 0 1 0 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 0 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 1
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
全1阵:xones(158)
>> xones(158)
x
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1
全0阵:xzeros(158)
>> xzeros(158)
x
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
均匀分布机阵([11])间:xunifrnd(11158)
>> xunifrnd(11158)
x
02155 05310 03192 06286 05075 03776 09923 06363
03110 05904 01705 05130 02391 00571 08436 04724
06576 06263 05524 08585 01356 06687 01146 07089
04121 00205 05025 03000 08483 02040 07867 07279
09363 01088 04898 06068 08921 04741 09238 07386
04462 02926 00119 04978 00616 03082 09907 01594
09077 04187 03982 02321 05583 03784 05498 00997
08057 05094 07818 00534 08680 04963 06346 07101
06469 04479 09186 02967 07402 00989 07374 07061
03897 03594 00944 06617 01376 08324 08311 02441
03658 03102 07228 01705 00612 05420 02004 02981
09004 06748 07014 00994 09762 08267 04803 00265
09311 07620 04850 08344 03258 06952 06001 01964
01225 00033 06814 04283 06756 06516 01372 08481
02369 09195 04914 05144 05886 00767 08213 05202
正态分布机阵(均值1标准差2):xnormrnd(12158)
>> xnormrnd(12158)
x
06627 01781 17827 08643 12703 05020 00156 10827
09584 04125 19034 06096 20305 11284 03588 04683
13128 06959 07394 05648 15228 42069 10249 09384
00671 12403 13674 03938 08830 34694 50584 14647
30053 60520 00477 10461 06753 05407 00860 18528
29285 43110 27240 11026 07079 20123 34849 02544
20401 16151 17234 26521 00640 01107 11334 05271
09599 15142 19101 40540 43642 06881 28675 50474
09305 07309 06974 19338 07515 15521 17006 35167
05963 06469 03302 05806 00324 04777 09420 54589
30374 25828 21056 22504 04240 18868 13649 16751
07336 16640 30782 13665 13484 17838 21301 30001
04291 36597 12353 10595 06155 15014 08309 23283
37028 18982 35213 28984 04519 08959 42079 01801
05505 16670 23203 16141 40601 04822 11967 04439
>> x(x<1)0
>> x(x>1)1
x
0 0 1 0 1 0 0 1
0 0 1 0 1 0 0 0
0 0 0 0 1 1 1 0
0 0 1 0 0 1 0 1
0 1 0 1 0 0 0 1
1 1 1 1 0 0 1 0
1 1 0 1 0 0 0 0
0 0 1 1 1 0 1 1
0 0 0 1 0 1 1 0
0 0 0 0 0 0 0 1
1 1 1 1 0 1 1 1
0 0 1 1 0 1 0 1
0 0 0 0 0 0 0 0
1 0 1 1 0 0 1 0
0 1 1 1 1 0 1 0
第2题:
afix((100+1)*rand(10)+0)
>> afix((100+1)*rand(10)+0)
a
8 1 7 7 4 3 8 9 3 0
9 10 0 0 4 7 2 2 9 0
1 10 9 3 8 7 5 8 6 5
10 5 10 0 8 1 7 2 6 8
6 8 7 1 2 1 9 10 10 10
1 1 8 9 5 5 10 3 3 1
3 4 8 7 4 10 6 2 8 6
6 10 4 3 7 3 1 2 8 5
10 8 7 10 7 6 1 6 4 0
10 10 1 0 8 2 2 5 6 3
bsum(sum(a>5))
>> bsum(sum(a>5))
b
59
第3题:
a[000010001]
a
0 0 0
0 1 0
0 0 1
>> a(find(sum(abs(a)1)0))[]
>> a(find(sum(abs(a)1)0))[]
a
1 0
0 1
第4题:
randint(1010[11000])
>> randint(1010[11000])
ans
815 158 656 707 439 277 752 841 352 76
906 971 36 32 382 680 256 255 831 54
127 958 850 277 766 656 506 815 586 531
914 486 934 47 796 163 700 244 550 780
633 801 679 98 187 119 891 930 918 935
98 142 758 824 490 499 960 350 286 130
279 422 744 695 446 960 548 197 758 569
547 916 393 318 647 341 139 252 754 470
958 793 656 951 710 586 150 617 381 12
965 960 172 35 755 224 258 474 568 338
>> Alength(find(mod(ans2)1))
>> Blength(find(isprime(ans)))
B
14
>> Alength(find(mod(ans2)1))
A
38
第5题:
>> x00011000
y12*x+5
y2x^23*x+1
plot(xy1'^'xy2' *')
legend('y1''y2')
第6题:
[xy]meshgrid(00254*pi)
>> zsin(x)*cos(y)*exp(sqrt(x^2+y^2))
>> subplot(121)
>> mesh(xyz)
>> title('mesh(xyz)')
>> subplot(122)
>> meshc(xyz)
>> title('meshc(xyz)')
第7题:
subplot(131)
>> pie3([158101253])
>> subplot(132)
>> bar3([158101253])
>> subplot(133)
>> stem3([158101253])
第8题:
>> x8058
y[]
for x0x
if x0>3&x0<1
y[y(x0^24*x03)2]
elseif x0>1&x0<1
y[yx0^2+1]
elseif x0>1&x0<3
y[y(x0^2+4*x03)2]
else y[y[]]
end
end
y
y
Columns 1 through 7
0 0 0 0 0 0 0
Columns 8 through 14
0 0 0 0 03750 05000 03750
Columns 15 through 21
0 07500 10000 07500 0 03750 05000
Columns 22 through 28
03750 0 0 0 0 0 0
Columns 29 through 33
0 0 0 0 0
第9题:
(两种方法)
法:
>> a1
b2
sum0
for k115
cba
sumsum+c
tb
ba+b
at
end
sum
sum
245701
法二:
>> a(1)2
b(1)1
a(2)3
b(2)2
sa(1)b(1)+a(2)b(2)
for i315
a(i)a(i1)+a(i2)
b(i)a(i1)
n(i)a(i)b(i)
ss+n(i)
end
>> s
s
245701
第10题:
>> Xrandint(120[1099])
bfloor(X)
pmean(b)
mfind(b
cb(m)
nfind(mod(c2)0)
dc(n)
d
66 18 24 22
第11题:
>> aprimes(100)
a
Columns 1 through 13
2 3 5 7 11 13 17 19 23 29 31 37 41
Columns 14 through 25
43 47 53 59 61 67 71 73 79 83 89 97
第12题:
>> a1b2sum0s0m0
for k120
na*b
sumsum+n
aa+1
ba+1
end
sum
for k2130
na*b
ssum+n
aa+1
ba+1
end
s
for k3140
na*b
ms+n
aa+1
ba+1
end
m
um(s+sum)
sum
3080
s
4010
m
5650
u
07969
第13题:
>>arandint(110[1099])
a
24 81 38 57 24 64 33 68 72 77
>> [bi]sort(a'descend')
b
81 77 72 68 64 57 38 33 24 24
i
2 10 9 8 6 4 3 7 1 5
>> c(i)b
>> c
第14题:
>> t110
y[4842436237543368 316930383034301630123005]
uexp(t)
ppolyfit(uy1)
tt100510
uuexp(tt)
yy1polyval(puu)
z1polyval(pu)
wucha1sqrt(sum((z1y)^2))
vt*u
qpolyfit(vy1)
vvtt*uu
yy2polyval(qvv)
z2polyval(qv)
wucha2sqrt(sum((z2y)^2))
figure(1)
plot(ty'*'ttyy1tz1'x')
figure(2)
plot(ty'+'ttyy2tz2'o')
wucha1
07280
wucha2
00375
figure(1)
figure(2)
第15题:
第:
function ffesin(x)
fexp(2*x)
>> [z1n]quad('fesin'02)
z1
04908
n
25
第二:
>> x00012
yexp(2*x)
trapz(xy)
ans
268000
第三:
function ffesin(x)
fx^23*x+05
>> z3quad('fesin'11)
z3
16667
第四:
>> finline('exp(x^22)*sin(x^2+y)''x''y')
>> Idblquad(f2211)
I
15745
第16题:
第问:
t000125
[xy]dsolve('Dx05x''Dyx4*y''x(0)1''y(0)05''t')
x
1(2*exp(t)) + 12
y
1(6*exp(t)) 19(24*exp(4*t)) + 18
x11(2*exp(t)) + 12 出数
>> y11(6*exp(t)) 19(24*exp(4*t)) + 18
>> plot(tx1ty1)
第二问:
>> ydsolve('x*D2y+(15)*Dy+y0''y(0)0Dy(0)0''x')
y
C6*x^(52)*besselj(5 2*x^(12))
第17题:
t[0 03 08 11 16 23]
y[05 082 114 125 135 141]
tt000123
apolyfit(ty2)
yy1polyval(att)
z1polyval(at)
wucha1sqrt(sum((z1y)^2))
B[ones(size(t')) (exp(t))' ( t*exp(t))']
bB\y'
yy2b(1)+b(2)*exp(tt)+b(3)*tt*exp(tt)
z2b(1)+b(2)*exp(t)+b(3)*t*exp(t)
wucha2sqrt(sum((z2y)^2))
figure(1)
plot(ty'+'ttyy1tz1'o')
figure(2)
plot(ty'+'ttyy2tz2'o')
a
02346 09134 05326
wucha1
00720
b
00625
06789
02320
wucha2
02065
figure(1)
figure(2)
第18题:
第问:
>> x10011
yexp(x)15*cos(2*pi*x)
>> y00
>> plot(xy'r'xy0'g')
function fxfunx(x)
fxexp(x)15*cos(2*pi*x)
>> yfzero('fumx'08)
y
07985
>> yfzero('fumx'018)
y
01531
>> yfzero('fumx'018)
y
01154
第二问:
function yfe(x)
yexp(x)15*cos(2*pi*x)
极值>> xfminsearch('fe'0202)
x
00166
>> x00166
yexp(x)15*cos(2*pi*x)
y
05083
值
>> xfminsearch('fe'11)
x
10062
>> x110062
y1exp(x1)15*cos(2*pi*x1)
y1
11333
>> x10011
yexp(x)15*cos(2*pi*x)
>> x110062
>> y111333
>> plot(xy'g'x1y1'+')
值
>> xfminsearch('f1'0406)
x
05288
>> x05288
>> yexp(x)+15*cos(2*pi*x)
y
31724
值y31724
极值
>> xfminsearch('f1'0604)
x
04897
>> x04897
>> yexp(x)+15*cos(2*pi*x)
y
21097
极值y21097
第19题:
第问
>> A[101011023010]
>> b[976]'
>> xA\b
x
09980
09797
08994
第二问
function qmyfun(p)
xp(1)
yp(2)
zp(3)
q(1)sin(x)+y^2+log(z)7
q(2)3*x+2^yz^3+1
q(3)x+y+z5
>> xfsolve('myfun'[111])
Equation solved
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance and
the problem appears regular as measured by the gradient
x
05991 23959 20050
第20题:
>> syms x
fsin(x^2)
taylor(fx12)
ans
x^10120 x^66 + x^2
第21题:
绘制散点图:
图1:牙膏销售量价格差散点图
图1知牙膏销售量价格差间存强正线性相关
图2:牙膏销售量广告费散点图
图2知牙膏销售量广告费间存较强正线性相关
元线性回分析
里采筛选策略SPSS动完成解释变量选择观测步检验变化情况进行残差分析异常点探测分析结果表()—表(四)
输入/移变量a
模型
输入变量
移变量
方法
1
广告费百万元x2 价格差x1b
输入
a 变量 销售量百万支y
b.已输入请求变量
牙膏销售量分析结果()
模型
R
R 方
调整 R 方
标准 估计误差
DurbinWatson
1
0941a
0886
0878
023833
1627
a 预测变量 (常量) 广告费百万元x2 价格差x1
b 变量 销售量百万支y
表()知调整判定系数0878较高说明销售量价格差广告费具较强线性关系方程DW检验值1627残差存定程度正相关
牙膏销售量分析结果(二)
Anovaa
模型
方
df
均方
F
Sig
1
回
11925
2
5962
104967
0000b
残差
1534
27
03057
总计
13459
29
a 变量 销售量百万支y
b 预测变量 (常量) 广告费百万元x2 价格差x1
表(二)知果显著性水a005回方程显著性检验相伴概率值显著性水a解释变量解释变量间线性关系显著建立线性模型恰
牙膏销售量分析结果(三)
系数
模型
非标准化系数
标准系数
t
Sig
B
标准化误差
试版
1
(常量)
4407
0722
6102
0000
价格差x1
1588
0299
0530
5304
0000
广告费百万元x2
0563
0119
0473
4733
0000
a 变量 销售量百万支y
表(三)展示模型中解释变量偏回系数偏回系数显著性检验情况果显著性水a005回系数显著性检验相伴概率值显著水a价格差广告费解释变量间线性关系显著保留模型中合理终回方程:
牙膏销售量y4407+1588×价格差x1+0563×广告费x2
牙膏销售量分析结果(四)
残差统计量a
值
值
均值
标准化偏差
N
预测值
71275
94457
83827
064125
30
残差
49779
58106
000000
022997
30
标准化预测值
1957
1658
0000
1000
30
标准化残差
2089
2438
0000
0965
30
a 变量 销售量百万支y
表(四)知标准化残差值2438绝值3标准化残差中没出现异常值
标准化残差标准化预测值Spearman等级相关分析结果(五)
Correlations
标准化预测值
标准化残差
Spearman's rho
标准化预测值
相关系数
1000
0042
Sig (2tailed)
00
0824
N
30
30
标准化残差
相关系数
0042
1000
Sig (2tailed)
0824
00
N
30
30
图3中着标准化预测值变化残差点0线周围机分布表(五)知残差预测值Spearman等级相关系数 0042果显著性水a005相伴概率值0824005应拒绝等级相关分析原假设认解释变量残差间存显著相关关系没出现异方差现象
图3:牙膏销售量残差图
第22题:
模型窗口中输入代码:
maxx+2*y
2*x+y12<0
3*x2*y+10>0
x4*y+10<0
然点击运行钮结果:
Global optimal solution found
Objective value 1800000
Infeasibilities 0000000
Total solver iterations 2
Variable Value Reduced Cost
X 2000000 0000000
Y 8000000 0000000
Row Slack or Surplus Dual Price
1 1800000 1000000
2 0000000 1142857
3 0000000 04285714
4 2000000 0000000
结果知值18理值5
第23题:
设x1x2x3x4x5x6x7分星期二三四五六日刚班数根题意建立数学模型:
Zx1+x2+x3+x4+x5+x6+x7
x1+x4+x5+x6+x7>28
x1+x2+x5+x6+x7>15
x1+x2+x3+x6+x7>24
x1+x2+x3+x4+x7>25
x1+x2+x3+x4+x5>19
x2+x3+x4+x5+x6>31
x3+x4+x5+x6+x7>28
模型窗口中输入代码:
minx1+x2+x3+x4+x5+x6+x7
x1+x4+x5+x6+x7>28
x1+x2+x5+x6+x7>15
x1+x2+x3+x6+x7>24
x1+x2+x3+x4+x7>25
x1+x2+x3+x4+x5>19
x2+x3+x4+x5+x6>31
x3+x4+x5+x6+x7>28
@gin(x1)
@gin(x2)
@gin(x3)
@gin(x4)
@gin(x5)
@gin(x6)
@gin(x7)
运行:
Global optimal solution found
Objective value 3600000
Objective bound 3600000
Infeasibilities 0000000
Extended solver steps 0
Total solver iterations 5
Variable Value Reduced Cost
X1 5000000 1000000
X2 3000000 1000000
X3 5000000 1000000
X4 1200000 1000000
X5 0000000 1000000
X6 1100000 1000000
X7 0000000 1000000
Row Slack or Surplus Dual Price
1 3600000 1000000
2 0000000 0000000
3 4000000 0000000
4 0000000 0000000
5 0000000 0000000
6 6000000 0000000
7 0000000 0000000
8 0000000 0000000
该商场需配备数值:36
第24题:
模型窗口中输入代码:
min2*x1^2+x2^2+2*x3^2+x1*x3x1*x2+x1+2*x2
x1^2+x2^2x3<0
x1+x2+2*x3<16
x1x2+x3<0
结果:
Local optimal solution found
Objective value 0000000
Infeasibilities 0000000
Extended solver steps 5
Total solver iterations 119
Variable Value Reduced Cost
X1 0000000 1000000
X2 0000000 2000000
X3 0000000 0000000
Row Slack or Surplus Dual Price
1 0000000 1000000
2 0000000 0000000
3 1600000 0000000
4 0000000 0000000
f(x)值:0
第25题:
模型窗口中输入代码:
min(x11)^2+(x22)^2
x1+x22<0
x1<0
x2<0
x1+x21<0
结果:
Local optimal solution found
Objective value 05000000
Infeasibilities 0000000
Extended solver steps 5
Total solver iterations 54
Variable Value Reduced Cost
X1 05000000 0000000
X2 1500000 0000000
Row Slack or Surplus Dual Price
1 05000000 1000000
2 0000000 1000000
3 05000000 0000000
4 1500000 0000000
5 0000000 0000000
值:05
文档香网(httpswwwxiangdangnet)户传
《香当网》用户分享的内容,不代表《香当网》观点或立场,请自行判断内容的真实性和可靠性!
该内容是文档的文本内容,更好的格式请下载文档