Matlab与数学建模综合练习
更新时间:2024-01-02 13:40:01 阅读量: 教育文库 文档下载
《Matlab与数学建模》综合练习
1.按顺序进行如下的操作:
(1)产生一个5阶魔术方阵A;并计算A'与A-1(即inv(A)); >> A=magic(5) A =
17 24 1 23 5 7 4 6 13 10 12 19 11 18 25
>> A'
ans =
17 23 4 24 5 6 1 7 13 8 14 20 15 16 22 >> inv(A)
ans =
-0.0049 0.0512 0.0431 -0.0373 -0.0303 0.0031 0.0047 -0.0065 0.0028 0.0050
(2)求A的特征值;>> P=poly(A) P =
1.0e+006 *
0.0000 -0.0001
>> roots(P)
8 15 14 16 20 22 21 3 2 9 10 11 12 18 19 25 21 2
3 9 -0.0354 0.0012 0.0034 -0.0046 0.0127 0.0015 0.0031 0.0031 0.0364 0.0108 0.0435 -0.0370 0.0415 -0.0450 0.0111 -0.0006 0.0406 0.0780 - 1 -
-5.0700
ans =
65.0000 -21.2768 -13.1263 21.2768 13.1263 >> V=eig(A) V =
65.0000 -21.2768 -13.1263 21.2768 13.1263
(3)计算A的各列的总和与平均值; >> sum(A(:,1))
ans =
65
>> mean(A(:,1))
ans =
13
>> sum(A)
ans =
65 65 65 65 65
>> mean(A)
ans =
13 13 13 13 13
(魔方矩阵的行、列、对角线上元素的和相等)
- 2 -
(4)计算A的各行的总和与平均值; >> sum(A(1,:))
ans =
65
>> mean(A(1,:))
ans =
13
>> sum(A,2)
ans =
65 65 65 65 65
>> mean(A,2)
ans =
13 13 13 13 13
(5)若b=[1 2 3 4 5] ',求方程组 Ax=b的解; >> b=[1 2 3 4 5]' b =
1 2 3 4 5
>> x=A\\b
- 3 -
x =
1/78 1/78 7/39 1/78 1/78
(6)验证你的结论的正确性. >> x=[1/78 1/78 7/39 1/78 1/78]' x =
1/78 1/78 7/39 1/78 1/78
>> A=magic(5) A =
17 24 23 5 4 6 10 12 11 18
>> A*x
ans =
1 2 3 4 5
2.产生行向量S =[1.0, 1.2, 1.4, …, >> S=1:0.2:20; >> S'; >> S*S'
1 8 15 7 14 16 13 20 22 19 21 3 25 2 9 20],并计算S * S' 与 S' * S,你有何“发现”?- 4 -
ans =
1.3533e+004
>> S'*S
ans =......
1行n列?n行1列=1行1列 n行1列?1行n列=n行n列
3.设A=???12??55???;B=??05??;求C=A * B – B * A,你有何“发现”? 34????>> A=[1 2;3 4]
A =
1 2 3 4
>> B=[5 5;0 5] B =
5 5 0 5
>> C=A*B-B*A C =
-15 -15 0 15
4.若设矩阵A=??>> A=[1 2;3 4] A =
1 2 3 4
- 5 -
?12??50????;B=;求C=A * B – B * A,你又有何“发现”? ????34??05?
>> B=[5 0;0 5] B =
5 0 0 5
>> C=A*B-B*A C =
0 0 0 0
5.如何建立如下的矩阵(命令方式和程序方式)?
??20040?0?(1)?02004?0?????????;
??00?2004???10?10命令式:
>> D=diag(2004*ones(10,1)) D =
2004 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 程序方式: 建立M文件: A=zeros(10); for i=1:10
for j=1:10 if i==j
A(i,j)=2004;
- 6 -
0 0 0 0 0 0 0 0 0 0 0 0 0 0 2004 0 0 2004 0 0 0 0 0 0 0 0 0 0 0 2004
end end end A
运行结果: A =
2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004
??010?10???(2)100?10????????; ??1010?0???10?10命令式:
>> A=10*ones(10) A =
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
>> L=tril(A,-1) L =
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 - 7 -
0 0 0 0 0 0 0 0 0 0
10 0 0 0 0 0 0 0 0 0 10 10 0 0 0 0 0 0 0 0 10 10 10 0 0 0 0 0 0 0 10 10 10 10 0 0 0 0 0 0 10 10 10 10 10 0 0 0 0 0 10 10 10 10 10 10 0 0 0 0 10 10 10 10 10 10 10 0 0 0 10 10 10 10 10 10 10 10 0 0 10 10 10 10
>> U=triu(A,1) U =
0 10 10 10 0 0 10 10 0 0 0 10 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
>> L+U
ans =
0 10 10 10 10 0 10 10 10 10 0 10 10 10 10 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 程序式:
A=zeros(10); for i=1:10 for j=1:10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 10 10 0 0 10 0 0 0 0 0 0 0 0 0 0 0 0 10 10 10 10 10 10 10 10 10 10 10 10 0 10 10 10 0 10 10 10 0 10 10 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 10 10 0 0 10 0 0 0 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 0 10 10 10 0 10 10 10 0
- 8 -
if i==j
A(i,j)=0; else
A(i,j)=10; end end end A
运行结果: A =
0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10 0 10 10 10 10 10 10 10 10 10
??20041?1?(3)?12004?1???; ??????
???11?2004??10?10命令式:
>> D=diag(2004*ones(10,1)); >> A=ones(10); >> L=tril(A,-1); >> U=triu(A,1); >> D+L+U
ans =
2004 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 - 9 -
10 10 10 10 10 10 10 10 10 0
1 1 1 1 1 1 1 1 1 1 1 1 1 1 2004 1 1
1 1 1 1 1
1
1
1 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 1 1 1 2004
>> D=diag(2004*ones(10,1)) D =
2004 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> A=ones(10) A =
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
>> L=tril(A,-1) L =
0 0 0 0 1 0 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 0 2004 0 0 2004 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 1 1 0 0 0 0 0 0 0 0 0 0 0 2004 0 0 0 2004 0 0 0 2004 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
- 10 -
0 0 0 0 0 0 0 0 0 0 0 0 2004 0 0 2004 0 0 0 0 0 0 0 0 0 0 2004
1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 1 0
>> U=triu(A,1) U =
0 1 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0
>> D+L+U
ans =
2004 1 1 1 1 1 2004 1 1 1 1 1 2004 1 1 1 1 1 2004 1 1 1 1 1 2004 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 程序式:
A=zeros(10); for i=1:10 for j=1:10 if i==j
A(i,j)=2004; else
A(i,j)=1; end end end
1 1 1 1 1 1 1 1 1 1 2004 1 1 2004 1 1 1 1 1 1 - 11 -
1 1 1 1 1 1 1 1 1 1 1 1 1 1 2004 1 1 2004 1 1 1 1 1 1 1 1 1 1 1 2004
A
运行结果: A =
2004 1 1 1 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 2004 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
??10?10??10?(4)??1010??10?????????
???10?10?10???10?10命令式:
>> D=diag(10*ones(10,1)) D =
10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 10
>> A=10*ones(10) A =
10 10 10 10 10 10 10 10 10 10
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
- 12 -
1 1 1 1 2004 1 1 2004 1 1 1 1 1 1 2004
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10
>> L=-1*tril(A,-1) L =
0 0 0 0 0 0 0 0 0 0 -10 0 0 0 0 0 0 0 0 0 -10 -10 0 0 0 0 0 0 0 0 -10 -10 -10 0 0 0 0 0 0 0 -10 -10 -10 -10 0 0 0 0 0 0 -10 -10 -10 -10 -10 0 0 0 0 0 -10 -10 -10 -10 - 10 -10 0 0 0 0 -10 -10 -10 -10 -10 -10 -10 0 0 0 -10 -10 -10 -10 -10 -10 -10 -10 0 0 -10 -10 -10 -10 -10 -10 -10 -10 -10 0
>> U=-1*triu(A,1) U =
0 -10 -10 -10 -10 -10 -10 -10 -10 -10 0 0 -10 -10 -10 -10 -10 -10 -10 -10 0 0 0 -10 -10 -10 -10 -10 -10 -10 0 0 0 0 -10 -10 -10 -10 -10 -10 0 0 0 0 0 -10 -10 -10 -10 -10 0 0 0 0 0 0 -10 -10 -10 -10 0 0 0 0 0 0 0 -10 -10 -10 0 0 0 0 0 0 0 0 -10 -10 0 0 0 0 0 0 0 0 0 -10 0 0 0 0 0 0 0 0 0 0
>> D+L+U
ans =
10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10
- 13 -
-10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10
程序式:
A=zeros(10); for i=1:10 for j=1:10 if i==j
A(i,j)=10; else
A(i,j)=-10; end end end A
运行结果: A =
10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10
??100?0?(5) ?120?0????????? ??11?10???0命令式:
>> D=[10:10:100]' D =
10
-10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 -10 10 -10 -10 -10 10 -10 -10 -10 10
- 14 -
20 30 40 50 60 70 80 90 100
>> D=diag(D,0) D =
10 0 0 0 20 0 0 0 30 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> A=ones(10) A =
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
>> L=tril(A,-1) L =
0 0 0 0 0 0 0 0 0 40 0 0 0 50 0 0 0 60 0 0 0 0 0 0 0 0 0 0 0 0 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 70 0 0 0 0 80 0 0 0 0 90 0 0 0 0 100
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
- 15 -
0 0 0 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0 0 0 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 0 0 0 1 1 1 1 1 1 1 1 0 0 1 1 1 1 1 1 1 1
>> D+L
ans =
10 0 0 0 0 0 0 0 1 20 0 0 0 0 0 0 1 1 30 0 0 0 0 0 1 1 1 40 0 0 0 0 1 1 1 1 50 0 0 0 1 1 1 1 1 60 0 0 1 1 1 1 1 1 70 0 1 1 1 1 1 1 1 80 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 程序式:
A=zeros(10); for i=1:10 for j=1:10 if i==j
A(i,j)=10*i; elseif i A(i,j)=1; end end end A 运行结果: A = 10 0 0 0 0 0 0 0 0 0 1 20 0 0 0 0 0 0 0 0 1 1 30 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 90 0 1 100 - 16 - 1 1 1 40 0 0 0 0 0 0 1 1 1 1 50 0 0 0 0 0 1 1 1 1 1 60 0 0 0 0 1 1 1 1 1 1 70 0 0 0 1 1 1 1 1 1 1 80 0 0 1 1 1 1 1 1 1 1 90 0 1 1 1 1 1 1 1 1 1 100 ??11?23?11(6) ??34?????11?1112命令式: >> format rat >> H=hilb(11) H = 1 1/2 1/2 1/3 1/3 1/4 1/4 1/5 1/5 1/6 1/6 1/7 1/7 1/8 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 >> H(:,11)=[] H = 1 1/2 1/2 1/3 1/3 1/4 1/4 1/5 1/5 1/6 1/6 1/7 1/7 1/8 1?11?1??12??? ?1?20?? 1/3 1/4 1/4 1/5 1/5 1/6 1/6 1/7 1/7 1/8 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/3 1/4 1/4 1/5 1/5 1/6 1/6 1/7 1/7 1/8 1/8 1/9 1/9 1/10 1/5 1/6 1/7 1/6 1/7 1/8 1/7 1/8 1/9 1/8 1/9 1/10 1/9 1/10 1/11 1/10 1/11 1/12 1/11 1/12 1/13 1/12 1/13 1/14 1/13 1/14 1/15 1/14 1/15 1/16 1/15 1/16 1/17 1/5 1/6 1/6 1/7 1/7 1/8 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 - 17 - 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 1/16 1/17 1/17 1/18 1/18 1/19 1/7 1/8 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 1/16 1/17 1/17 1/18 1/18 1/19 1/19 1/20 1/20 1/21 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 ???? 1/8 1/9 1/10 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/9 1/10 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18 1/10 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18 1/19 1/11 1/12 1/13 1/14 1/15 1/16 1/17 1/18 1/19 1/20 >> H(1,:)=[] H = 1/2 1/3 1/4 1/5 1/3 1/4 1/5 1/6 1/4 1/5 1/6 1/7 1/5 1/6 1/7 1/8 1/6 1/7 1/8 1/9 1/7 1/8 1/9 1/10 1/8 1/9 1/10 1/11 1/9 1/10 1/11 1/12 1/10 1/11 1/12 1/13 1/11 1/12 1/13 1/14 程序式: format rat A=zeros(10); for i=1:10 for j=1:10 A(i,j)=1/(i+j); end end A 运行结果: A = 1/2 1/3 1/4 1/5 1/3 1/4 1/5 1/6 1/4 1/5 1/6 1/7 1/5 1/6 1/7 1/8 1/6 1/7 1/8 1/9 1/7 1/8 1/9 1/10 1/8 1/9 1/10 1/11 1/9 1/10 1/11 1/12 1/10 1/11 1/12 1/13 1/11 1/12 1/13 1/14 1/6 1/7 1/7 1/8 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 1/6 1/7 1/7 1/8 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 - 18 - 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 1/16 1/17 1/17 1/18 1/8 1/9 1/9 1/10 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 1/16 1/17 1/17 1/18 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 1/16 1/17 1/17 1/18 1/18 1/19 1/19 1/20 1/10 1/11 1/11 1/12 1/12 1/13 1/13 1/14 1/14 1/15 1/15 1/16 1/16 1/17 1/17 1/18 1/18 1/19 1/19 1/20 ??2004200?0200430(7)??002004?000??000>> D=[20:10:50]' D = 20 30 40 50 >> D=diag(D,1) D = 0 20 0 0 0 0 0 30 0 0 0 0 0 40 0 0 0 0 0 50 0 0 0 0 0 >> V=diag(2004*ones(5,1)) V = 2004 0 0 0 2004 0 0 0 2004 0 0 0 0 0 0 >> D+V ans = 2004 20 0 0 2004 30 0 0 2004 0 0 0 0 0 0 00?00?400??200450? ?02004?? 0 0 0 0 0 0 2004 0 0 2004 0 0 0 0 40 0 2004 50 0 2004 - 19 - 程序式: A=zeros(5); for i=1:5 for j=1:5 if i==j A(i,j)=2004; elseif i+1==j A(i,j)=10*j; else A(i,j)=0; end end end A 运行结果: A = 2004 20 0 0 0 0 2004 30 0 0 0 0 2004 40 0 0 0 0 2004 50 0 0 0 0 2004 6.绘制下列曲线的图形(散点图与折线图):y?>> x=[-1:0.1:2]; >> y=(x.^3-x.^2-x+1).^(1/3); >> plot(x,y,'.') 3x3?x2?x?1,x?[?1,2] - 20 - >> x=[-1:0.5:2]; >> y=(x.^3-x.^2-x+1).^(1/3); >> plot(x,y) - 21 - 7.绘制下列曲面的图形:z?x?2y>> x=-4:0.2:4;y=x; >> [X,Y]=meshgrid(x,y); >> Z=(X.^2+2.*Y.^2).^(1/2); >> surf(X,Y,Z) >> hold on >> Z=-(X.^2+2.*Y.^2).^(1/2); >> surf(X,Y,Z) 222(提示:曲面由两部分构成) - 22 - 8.在同一个图形上作下列两个函数的图象: (1)y?sin(x),x?[0,2?]; (2)y?cos(x),x?[0,2?] >> x=0:0.2:2*pi; >> y=sin(x).^2; >> plot(x,y,'--m') >> hold on >> y=cos(x).^2; >> plot(x,y,'-b') 22 - 23 - - 24 - >> x=0:0.1:2*pi; >> subplot(2,1,1) >> plot(x,sin(x).^2) >> title('y=sin(x)^2') >> subplot(2,1,2) >> plot(x,cos(x).^2) >> title('y=cos(x)^2') 9.假如你有一组实测数据,例如: x=[53 56 60 67.5 75 90 110]; y=[109 120.5 130 141.1 157.5 180 185]; 求其回归直线,画回归直线图形并计算最小误差平方和. >> x=[53 56 60 67.5 75 90 110]; >> y=[109 120.5 130 141.1 157.5 180 185]; >> plot(x,y) - 25 - >> [p,s]=polyfit(x,y,1) p = 1.3538 47.2362 s = R: [2x2 double] df: 5 normr: 20.8486 所以回归方程为:y=1.3538x+47.2362; 10.假如你有一组实测数据,例如: x=[75 86 95 108 112 116 135 151 155 160 163 167 171 178 185]; y=[10 12 15 17 20 22 35 41 48 50 51 54 59 66 75]; 求其回归直线,画回归直线图形并计算最小误差平方和. >> x=[75 86 95 108 112 116 135 151 155 160 163 167 171 178 185]; >> y=[10 12 15 17 20 22 35 41 48 50 51 54 59 66 75]; - 26 - >> plot(x,y) >> [p,s]=polyfit(x,y,1) p = 0.5805 -41.2700 s = R: [2x2 double] df: 13 normr: 16.2044 所以回归方程为: y=0.5805x+-41.2700; 12.求下列各结果: (1)用Matlab因式分解:x>> syms x - 27 - 100?1. >> f=x^100-1; >> factor(f) ans = (x-1)*(x^4+x^3+x^2+x+1)*(x^20+x^15+x^10+x^5+1)*(x+1)*(1-x+x^2-x^3+x^4)*(1-x^5+x^10-x^15+x^20)*(1+x^2)*(x^8-x^6+x^4-x^2+1)*(x^40-x^30+x^20-x^10+1) (2)用Matlab求极限:L?lim>> syms x >> f=((1+x)^(1/x)-exp(1))/x; >> L=limit(f,x,0) L = NaN (3)用Matlab求积分:>> syms x >> f=sin(x^2); >> int(f,x,0,inf) ans = 1/4*2^(1/2)*pi^(1/2) (4)用Matlab求幂级数: x?0(1?x)?e. x1x?0??sinx2dx. ?(?1)n?1?n?1x2n?14n?12的和函数(化简结果). >> syms x n >> Fn=(-1)^(n-1)*x^(2*n+1)/(4*n^2-1); >> S=symsum(Fn,n,1,inf) S = 1/3*x^3*(3/2*LerchPhi(-x^2,1,3/2)*(-1/2-1/2*x^2)+1/(x^2+1)*(3/2*x^2+3/2)) 14. (三维)符号作图尝试 命令 作用 - 28 - 解释 ezplot3 ezcontour ezcontourf ezmesh ezmeshc ezsurf ezsurfc 3-D parametric curve plotter use contour plotter filled contour plotter 3-D mesh plotter combination mesh/contour plotter 3-D colored surface plotter combination surf/contour plotter 3D参数曲线图形 等高线图 填充等高线图 3D mesh曲面图形 mesh曲面/等高线图 3D surf曲面图形 surf曲面/等高线图 请尝试以下的命令: ezplot3('sin(t)', ' cos(t)', 't', [0,6*pi]) >> ezplot3('sin(t)', ' cos(t)', 't', [0,6*pi]) ezcontour('x*exp(-x^2 - y^2)') >> ezcontour('x*exp(-x^2 - y^2)') - 29 - ezcontourf('x*exp(-x^2 - y^2)') >> ezcontourf('x*exp(-x^2 - y^2)') ezmesh('(s-sin(s))*cos(t)','(1-cos(s))*sin(t)','s',[-2*pi,2*pi]) >> ezmesh('(s-sin(s))*cos(t)','(1-cos(s))*sin(t)','s',[-2*pi,2*pi]) - 30 - ezmeshc('(s-sin(s))*cos(t)','(1-cos(s))*sin(t)','s',[-2*pi,2*pi]) >> ezmeshc('(s-sin(s))*cos(t)','(1-cos(s))*sin(t)','s',[-2*pi,2*pi]) ezsurf('x*exp(-x^2 - y^2)') >> ezsurf('x*exp(-x^2 - y^2)') - 31 - ezsurfc('x*exp(-x^2 - y^2)') >> ezsurfc('x*exp(-x^2 - y^2)') - 32 -
正在阅读:
Matlab与数学建模综合练习01-02
高效时间管理09-05
1.1《因式分解》word精品教案 鲁教版八年级上册09-01
初中语文要熟记的文学常识大全06-08
安全管理制度10-01
鲁迅《雪》08-21
党史知识竞赛100题01-18
幼儿园培训会议主持词11-17
青海省2015年上半年模具木工考试试卷01-01
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 数学建模
- 练习
- Matlab
- 综合
- 汽车理论习题集(附答案)
- 五年级下册数学教案-7.2 用倒序相加法求和 - 苏教版(2014秋)
- 八年级上学期物理知识点第1、2章
- 四柱式液压机液压系统设计
- 中西方古建筑比较
- 2012年上半年第四期团日活动材料
- 2019年湖北省武汉市硚口区中考数学模拟试卷(一)
- 中国会计准则变迁与会计理念变化
- 消防“为何从警、如何做警、为谁用警”主题演讲稿
- 面试时的经典问答和面试技巧
- 安徽电大工商管理本公司概论形考(答案)
- 第6课罗马法的起源与发展
- “单片机控制装置安装与调试”赛项竞赛规程
- 精编2019-2020学年人教版六年级数学上册期中测试卷(有标准答案)
- 马斯洛需求层次理论与赫兹伯格双因素理论异同
- 离子浓度大小比较导学案
- 影楼服务流程
- 武汉职业技术学院课程论文撰写规范及格式
- 江苏省南菁高级中学2011年录取情况
- 移动通信系统频率复用技术分析与比较