Matlab程序设计与应用第二版刘卫国课后实验答案Word下载.doc
- 文档编号:14175600
- 上传时间:2022-10-19
- 格式:DOC
- 页数:7
- 大小:66.50KB
Matlab程序设计与应用第二版刘卫国课后实验答案Word下载.doc
《Matlab程序设计与应用第二版刘卫国课后实验答案Word下载.doc》由会员分享,可在线阅读,更多相关《Matlab程序设计与应用第二版刘卫国课后实验答案Word下载.doc(7页珍藏版)》请在冰豆网上搜索。
disp(A+6*B);
disp('
A-B+I='
disp(A-B+eye(3));
A*B='
disp(A*B);
A.*B='
disp(A.*B);
A^3='
disp(A^3);
A.^3='
disp(A.^3);
A/B='
disp(A/B);
B\A='
disp(B\A);
[A,B]='
disp([A,B]);
[A([1,3],:
B^2]='
disp([A([1,3],:
B^2]);
T3:
z=1:
25;
A=reshape(z,5,5)'
;
B=[3,0,16;
17,-6,9;
0,23,-4;
9,7,0;
4,13,11];
C=A*B
D=C(3:
5,2:
3)
T4-1:
a=100:
999;
b=find(rem(a,21)==0);
c=length(b)
T4-2:
a=input('
请输入一个字符串:
'
'
s'
b=find(a>
='
A'
&
a<
Z'
a(b)=[];
disp(a);
实验二:
E=eye(3),R=rand(3,2),O=zeros(2,3),S=diag([1,2]);
A=[E,R;
O,S]
A^2='
disp(A^2);
[E,R+RS;
O,S^2]'
B=[E,R+R*S;
O,S^2]
H=hilb(5)
P=pascal(5)
Hh=det(H)
Hp=det(P)
Th=cond(H)
Tp=cond(P)
a=abs(Th-1);
b=abs(Tp-1);
ifa>
b
disp('
帕萨卡矩阵P性能更好'
elseifa<
希尔伯特矩阵H性能更好'
else
两个矩阵性能相同'
end
a=1:
A=reshape(a,5,5)
行列式的值:
disp(det(A));
矩阵的秩:
disp(rank(A));
矩阵的迹:
disp(trace(A));
矩阵的范数:
disp(norm(A));
T4:
A=[-29,6,18;
20,5,12;
-8,8,5]
[V,D]=eig(A)
T5:
A=[1/2,1/3,1/4;
1/3,1/4,1/5;
1/4,1/5,1/6]
B=[0.95,0.67,0.52]'
X1=A\B
B(3)=0.53
X2=A\B
系数矩阵A的条件数:
disp(cond(A));
T6:
B1=sqrtm(A)'
B1=sqrtm(A)
B2=sqrt(A)'
B2=sqrt(A)
B1*B1'
B1*B1
B2.*B2'
B2.*B2
实验三:
T1:
x=-5.0:
2:
5.0
fori=1:
length(x);
if(x(i)<
0)&
(x(i)~=-3)
y(i)=x(i)^2+x(i)-6;
elseif(x(i)>
=0)&
(x(i)<
5)&
(x(i)~=2)&
(x(i)~=3);
y(i)=x(i)^2-5*x(i)+6;
else
y(i)=x(i)^2-x(i)-1;
end
y
T2-if:
s=input('
pleaseenterthescore:
while(s<
0||s>
100)
disp('
thescoreisnotreasonable'
s=input('
if(s>
=90&
s<
=100);
elseif(s>
=80&
90);
B'
=70&
80);
C'
=60&
70);
D'
E'
T2-switch:
switchfix(s/10)
case{9,10}
case{8}
case{7}
case{6}
case{0,1,2,3,4,5}
t=input('
请输入工时time='
ift>
120
w=120*84+(t-120)*1.15*84;
elseift<
60
w=t*84-700;
w=84*t;
应发工资为:
disp(w);
a=10+floor(rand
(1)*89)
b=10+floor(rand
(1)*89)
请输入+或-或*或/'
while(s~='
+'
s~='
-'
*'
/'
)
输入的符号错误,请重新输入'
switchs
case{'
}
c=a+b;
c=a-b;
c=a*b;
c=a/b;
c
A=rand(5,6)
n=input('
请输入n:
while(n<
1)
输入的n有误,请重新输入'
n=input('
ifn>
5
B=A(5,:
B=A(n,:
End
实验四:
m=0;
n;
m=m+1/i^2;
pii=sqrt(6*m)
T1-2:
m=1./(1:
n).^2;
s=sum(m);
pii=sqrt(6*s)
T2:
n=1000;
y=0;
y=y+1/(2*i-1);
ify>
=3
disp('
最大n值为:
i-1
对应的y值为:
y-1/(2*i-1)
break;
formatlong
请输入a:
b=input('
请输入b:
x
(1)=a/(1.0+b);
i=1;
x
(2)=a/(x(i)+b);
while(abs(x(i+1)-x(i))>
0.00001&
i<
500)
i=i+1;
x(i+1)=a/(x(i)+b);
r1=(-b+sqrt(b^2+4*a))/2;
r2=(-b-sqrt(b^2+4*a))/2;
disp(['
x'
num2str(i+1),'
num2str(x(i+1),8)]);
num2str(i),'
num2str(x(i),8)]);
r1='
num2str(r1,8),'
r2='
num2str(r2,8)]);
formatshort
f
(1)=1;
f
(2)=0;
f(3)=1;
i=4;
while(i<
=100)
f(i)=f(i-1)-2*f(i-2)+f(i-3);
fmax=max(f)
fmin=min(f)
fsum=sum(f)
fp=length(find(f>
0))
fn=length(find(f<
f0=length(find(f==0))
j=0;
s=0;
fori=3:
50
m=i*(i-1)-1;
ifisprime(m)==1
m
s=s+m;
j=j+1;
亲密数的对数:
num2str(j)]);
所有亲密素数之和:
num2str(s)]);
实验五:
fn1:
functionf=fn1(n)
f=n+10*log(n.^2+5);
fn2:
functionf=fn2(n)
f=0;
n
f=f+i*(i+1);
fx:
functionf=fx(x)
f=1./((x-2).^2+0.1)+1./((x-3).^4+0.01);
x=input('
请输入一个复数:
fe=exp(x)
flg=log(x)
fsin=sin(x)
fcos=cos(x)
m1=input('
请输入m1:
m2=input('
请输入m2:
请输入theta:
A=[m1*cos(t),-m1,-sin(t),0;
m1*sin(t),0,...
cos(t),0;
0,m2,-sin(t),0;
0,0,-cos(t),1]
B=[0,m1*9.8,0,m2*9.8]'
[a1,a2,N1,N2]='
disp([A\B]'
j=1;
n=1;
k=1;
fori=10:
99%挑选出10~99中所有的素数
ifisprime(i)==1
m(j)=i;
j=j+1;
end
fort=1:
length(m);
s(n)=10*rem(m(t),10)+
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab 程序设计 应用 第二 卫国 课后 实验 答案