MATLAB程序设计教程第二版课后答案Word文件下载.docx
《MATLAB程序设计教程第二版课后答案Word文件下载.docx》由会员分享,可在线阅读,更多相关《MATLAB程序设计教程第二版课后答案Word文件下载.docx(22页珍藏版)》请在冰豆网上搜索。
(2)n=input('
ifn>
=90&
n<
=100
elseifn>
=80&
=89
=70&
=79
=60&
=69
else
(3)try
n;
catch
price='
erroe'
3
n=[1,5,56,4,3,476,45,6,3,76,45,6,4,3,6,4,23,76,908,6];
a=n
(1);
b=n
(1);
form=2:
20
ifn(m)>
a
a=n(m);
elseifn(m)<
b
b=n(m);
end
max=a
min=b
法2
min=min(n)
max=max(n)
4
b=[-3.0:
0.1:
3.0];
forn=1:
61
a=b(n);
y(n)=(exp(0.3*a)-exp(-0.3*a))/2*sin(a+0.3)+log((0.3+a)/2);
y
5
y1=0;
y2=1;
请输入n的值:
fori=1:
n
y1=y1+1/i^2;
y2=y2*((4*i*i)/((2*i-1)*(2*i+1)));
y1
y2
6
A=[1,1,1,1,1,1;
2,2,2,2,2,2;
3,3,3,3,3,3;
4,4,4,4,4,4;
5,5,5,5,5,5;
6,6,6,6,6,6];
请输入n的值:
ifn<
=5&
n>
=0
disp(A([n],:
));
elseifn<
disp(lasterr);
elsedisp(A([6],:
7
(1)
f=[];
40
f(n)=n+10*log(n^2+5);
y=f(40)/(f(30)+f(20))
(2)
a=0;
f(n)=a+n*(n+1);
a=f(n);
y=f(40)/(f(30)+f(20))
8
y=0;
m=input('
输入m的值:
输入n值:
y=y+i^m;
************************************************************
functions=shi8_1(n,m)
s=0;
s=s+i^m;
shi8_1(100,1)+shi8_1(50,2)+shi8_1(10,1/2)
思考练习
2
N=[1,2,3,4,5];
2.*N
N./2
1./N
1./N.^2
s=fix(100*rand(1,20)*9/10+10)
y=sum(s)/20
j=0;
ifs(i)<
y&
rem(s(i),2)==0
j=j+1;
A(j)=s(i);
elsecontinue;
A
y2=0;
y1=y1+-(-1)^i/(2*i-1);
y2=y2+1/4^i;
unit4
1
(1)
x=-10:
0.05:
10;
y=x-x.^3./6;
plot(x,y)
0.5:
ezplot('
x^2+2*y^2-64'
[-8,8]);
gridon;
t=-pi:
pi/10:
pi;
y=1./(1+exp(-t));
subplot(2,2,1);
bar(t,y);
title('
条形图(t,y)'
axis([-pi,pi,0,1]);
subplot(2,2,2);
stairs(t,y,'
b'
阶梯图(t,y)'
subplot(2,2,3);
stem(t,y,'
k'
杆图(t,y)'
subplot(2,2,4);
loglog(t,y,'
y'
对数坐标图(t,y)'
3
(1)
t=0:
pi/50:
2*pi;
r=5.*cos(t)+4;
polar(t,r);
\rho=5*cos\theta+4'
t=-pi/3:
pi/3;
r=5.*((sin(t)).^2)./cos(t);
4
(1)
x=exp(-t./20).*cos(t);
y=exp(-t./20).*sin(t);
z=t;
plot3(x,y,z);
gridon;
[x,y]=meshgrid(-5:
5);
z=zeros(11)+5;
mesh(x,y,z);
shadinginterp;
[x,y,z]=sphere(20);
surf(x,y,z);
axisoff;
m=moviein(20);
axis([-i,i,-i,i,-i,i])
m(:
i)=getframe;
movie(m,4);
x=-5:
5;
y=(1./(2*pi)).*exp((-(x.^2))/2);
plot(x,y);
t=-2*pi:
x=t.*sin(t);
y=t.*cos(t);
pi/1000:
x=sin(3.*t).*cos(t);
y1=sin(3.*t).*sin(t);
y2=2.*x-0.5;
plot(x,y1,'
x,y2);
holdon;
k=find(abs(y1-y2)<
1e-2);
x1=x(k);
y3=2.*x1-0.5;
plot(x1,y3,'
rp'
x=-2:
0.01:
2;
y=sin(1./x);
subplot(2,1,1);
subplot(2,1,2);
fplot('
sin(1./x)'
[-2,2],1e-4);
5
(1)
i=-4*pi:
j=12./sqrt(i);
polar(i,j);
{\rho}=12/sqrt(\theta)'
)
a=-pi/6:
pi/6;
b=3.*asin(a).*cos(a)./((sin(a)).^3+(cos(a)).^3);
polar(a,b);
6
(1)
[u,v]=meshgrid(-4:
4);
x=3.*u.*sin(v);
y=2.*u.*cos(v);
z=4.*u.^2;
[x,y]=meshgrid(-3:
0.2:
3);
z=-5./(1+x.^2+y.^2);
subplot(1,2,1);
subplot(1,2,2);
unit5
1
A=randn(10,5)
x=mean(A)
y=std(A)
Max=max(max(A))
Min=min(min(A))
Sumhang=sum(A,2)
SumA=sum(Sumhang)
B=sort(A);
C=sort(B,2,'
descend'
C
a=0:
15:
90;
b=a./180.*pi;
s=sin(b)
c=0:
75;
d=c./180.*pi;
t=tan(d)
e=input('
请输入想计算的值:
S=sin(e/180*pi)
T=tan(e/180*pi)
S1=interp1(a,s,e,'
spline'
T1=interp1(c,t,e,'
P1=polyfit(a,s,5);
P2=polyfit(c,t,5);
S2=polyval(P1,e)
T2=polyval(P2,e)
n=[1,9,16,25,36,49,64,81,100];
N=sqrt(n);
x=input('
jisuanzhi:
'
interp1(n,N,x,'
cubic'
N=64;
T=5;
t=linspace(0,T,N);
h=exp(-t);
dt=t
(2)-t
(1);
f=1/dt;
X=fft(t);
F=X(1:
N/2+1);
f=f*(0:
N/2)/N;
plot(f,abs(F),'
-*'
P=[2,-3,0,5,13];
Q=[1,5,8];
p=polyder(P)
q=polyder(P,Q)
[a,b]=polyder(P,Q)
P1=[1,2,4,0,5];
P2=[0,1,2];
P3=[1,2,3];
P=P1+conv(P2,P3)
X=roots(P)
A=[-1,1.2,-1.4;
0.75,2,3.5;
0,5,2.5];
p=polyval(P,A)
A=rand(1,30000);
a=mean(A)
b=std(A)
Max=max(A)
Min=min(A)
n=0;
30000
if(A(i)>
0.5)
n=n+1;
y=n/30000
p=[45,74,54,55,14;
78,98,45,74,12;
87,98,85,52,65]
[M,S]=max(p)
[N,H]=min(p)
junzhi=mean(p,1)
fangcha=std(p,1,1)
zong=sum(p,2);
[Max,wei]=max(zong)
[Min,wei]=min(zong)
[zcj,xsxh]=sort(zong,