MATLAB程序设计教程第二版课后答案Word下载.docx
- 文档编号:22566215
- 上传时间:2023-02-04
- 格式:DOCX
- 页数:26
- 大小:18.63KB
MATLAB程序设计教程第二版课后答案Word下载.docx
《MATLAB程序设计教程第二版课后答案Word下载.docx》由会员分享,可在线阅读,更多相关《MATLAB程序设计教程第二版课后答案Word下载.docx(26页珍藏版)》请在冰豆网上搜索。
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=[:
:
];
forn=1:
61
a=b(n);
y(n)=(exp*a)-exp*a))/2*sin(a++log(+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:
10;
y=x-x.^3./6;
plot(x,y)
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.*;
plot(x,y1,'
x,y2);
holdon;
k=find(abs(y1-y2)<
1e-2);
x1=x(k);
y3=2.*;
plot(x1,y3,'
rp'
x=-2:
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:
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,,;
2,;
0,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)>
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,'
x=[1:
10:
101];
y=[0,,,,,,,,,,];
[p,s]=polyfit(x,y,5)
a=1:
5:
101;
y1=polyval(p,a);
plot(x,y,'
o'
a,y1,'
unit6
A=[1/2,1/3,1/4;
1/3,1/4,1/5;
1/4,1/5,1/6];
p=[,,]'
x=A\p
cond(A)
x1=fzero(@funx1,-1)
functionfx=funx1(x)
fx=x^41+x^3+1;
x2=fzero(@funx2,
functionfx=funx2(x)
fx=x-sin(x)/x;
(3)
options=optimset('
Display'
'
off'
x=fsolve(@fun3,[1,1,1]'
options)
q=fun3(x)
functionq=fun3(p)
x=p
(1);
y=p
(2);
z=p(3);
q
(1)=sin(x)+y^2+log(z)-7;
q
(2)=3*x+2^y-z^3+1;
q(3)=x+y+z-5;
t0=0;
tf=5;
y0=1;
[t,y]=ode23(@fun4,[t0,tf],y0);
t'
functionyp=fun4(t,y)
yp=-+sin(10*t))*y;
[t,y]=ode23(@fun5,[t0,tf],y0);
functionyp=fun5(t,y)
yp=cos(t)-y/(1+t^2);
x=fminbnd(@mymin,0,2);
-mymin(x)
functionfx=mymin(x)
fx=-(1+x.^2)/(1+x.^4);
[x,fval]=fmincon(@fun6,[0,0,0],[],[],a,b,lb,ub)
-fval
functionf=fun6(x)
f=-(sqrt(x
(1))+(400-x
(1))*+(sqrt(x
(2))+(400-x
(1))*
(2))*+sqrt(3)+(((400-x
(1))*
(2))*(3))*+sqrt(x(x4)));
A=[2,3,5;
3,7,4;
1,-7,1];
B=[10,3,5]'
C1=inv(A)*B
C2=A\B
[L,U]=lu(A);
x=U\(L\B)
A=[6,5,-2,5;
9,-1,4,-1;
3,4,2,-2;
3,-9,0,2];
B=[-4,13,1,11]'
x1=fzero(@funx1,
fx=3*x+sin(x)-exp(x);
x1=fzero(@funx2,1)
fx=x-1/x+5;
x=fsolve(@fun3,[3,0]'
q
(1)=x^2+y^2-9;
q
(2)=x+y-1;
y0=[0,1];
[t,y]=ode45(@vdpol,[t0,tf],y0);
[t,y]
functionydot=vdpol(t,y);
ydot
(1)=(2-3*y
(2)-2*t*y
(1))./(1+t^2);
ydot
(2)=y
(1);
ydot=ydot'
y0=[1;
0;
2];
[t,y]=ode45(@vdpoll,[t0,tf],y0);
functionydot=vdpoll(t,y);
ydot
(1)=cos(t)-y(3)./(3+sin(t))+5*y
(1).*cos(2*t)/((t+1).^2)-y
(2);
ydot(3)=y
(2);
x=fminbnd(@mymin,0,pi);
fx=-sin(x)-cos(x.^2);
[x,y1]=fminbnd(@mymax,0,;
-y1
functionfx=mymax(x);
fx=-(9*x+4*x.^3-12*x.^2);
unit7
formatlong
fx=inline('
sin(x)./x'
[I,n]=quadl(fx,0,2,1e-10)
1./(.^2+-1./(.^2+-6'
[I,n]=quad(fx,0,1,1e-10)
globalki;
ki=0;
I=dblquad(@fxy,0,1,0,1)
ki
f=inline('
abs(cos(x+y))'
x'
I=dblquad(f,0,pi,0,pi)
X=:
F=[,,,,,,];
trapz(X,F)
p=0:
pi/5:
n
DX=diff(sin(p),n)
sin(x)./(x+cos(2.*x))'
g=inline('
(cos(x).*(x+cos(2*x))-sin(x).*(1-2.*sin(2*x)))/(x+cos(2.*x)).^2'
x=-pi:
p=polyfit(x,f(x),5);
dp=polyder(p);
dpx=polyval(dp,x);
%求dp在假设点的函数值
dx=diff(f([x,]))/;
%直接对f(x)求数值导数
gx=g(x);
%求函数f的导函数g在假设点的导数
plot(x,dpx,x,dx,'
.'
x,gx,'
-'
%作图
1./(1+x.^2)'
[I,n]=quad(fx,-Inf,Inf,1e-10)
[I,n]=quadl(fx,-Inf,Inf,1e-10)
x=-100000:
100000;
y=1./(1+x.^2);
trapz(x,y)
formatshort
log(1+x)./(1+x.^2)'
sqrt(cos(t.^2)+4*sin((2*t).^2)+1)'
[I,n]=quad(fx,0,2*pi,1e-10)
4.*x.*z.*exp(-z.^2.*y-x.^2)'
I=triplequad(f,0,pi,0,pi,0,1)
sin(x)'
cos(x)'
x=0:
dx=diff(f([x,2*pi+]))/;
unit8
symsxy;
s=x^4-y^4;
factor(s)
factor(5135)
symsx;
f=(x-2)/(x^2-4);
limit(f,x,2)
symx;
f=(sqrt(pi)-sqrt(acos(x)))/sqrt(x+1);
limit(f,x,-1,'
right'
f=sin(1/x);
diff(f,'
2)
f=(1-cos(2*x))/x;
f=sqrt(exp(x)+1);
int(f,'
f=x/(x+y);
f=exp(x)*(1+exp(x))^2;
0,log
(2))
f=x*log(x);
1,exp
(1))
s=symsum((-1)^(x+1)/x,1,Inf)
symy;
z=symsum(y^(2*y-1)/(2*y-1),1,Inf)
f1=(exp(x)+exp(-x))/2;
f2=sqrt(x^3-2*x+1);
taylor(f1,x,5,0)
taylor(f2,x,6,0)
7
symsxya;
x=solve('
x^3+a*x+1=0'
sin(x)+2*cos(x)-sqrt(x)=0'
[xy]=solve('
log(x/y)=9'
exp(x+y)=3'
symsn;
[x,y]=dsolve('
x*(D2y)+(1-n)*(Dy)+y=0'
y(0)=0'
Dy(0)=0'
symsxB1B2ab
s1=2*((cos(x))^2)-(sin(x))^2;
s2=sin(B1)*cos(B2)-cos(B1)*sin(B2);
s3=sqrt((a+sqrt(a^2-b))/2)+sqrt((a-sqrt(a^2-b))/2);
s4=(4*x^2+8*x+3)/(2*x+1);
h1=simplify(s1)
h2=simplify(s2)
h3=simplify(s3)
h4=simplify(s4)
symsxa;
f=abs(x)/x;
limit(f,x,0,'
left'
f=(x+a/x)^x;
limit(f,x,inf)
symsxym
f=sqrt(x+sqrt(x+sqrt(x)));
m=diff(f,'
diff(m,'
f=x+y-sqrt(x^2+y^2);
z1=diff(f,x)
z2=diff(f,y)
f=1/(asin(x)^2*(1-x^2)^(1/2));
int(f)
symsx
f=1/(1+x);
int(f,0,4)
f=x^3*sin(x)^2/(x^6+2*x^4+1);
int(f,-1,1)
symsn
s=symsum(1/4^n,1,inf)
symn;
s=symsum(((n+1)/n)^(1/2),1,inf)
eval(y)
symsx
f=tan(x
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- MATLAB 程序设计 教程 第二 课后 答案
![提示](https://static.bdocx.com/images/bang_tan.gif)