matlab习题及答案 下载本文

内容发布更新时间 : 2024/12/25 23:03:42星期一 下面是文章的全部内容请认真阅读。

(z-cos(a*T))*z/(z^2-2*z*cos(a*T)+1)

>> f1=iztrans(F) f1 =

cos(a*T*n) (2)

>> syms k T a;f=(k*T)^2*exp(-a*k*T);F=ztrans(f) F =

T^2*z*exp(-a*T)*(z+exp(-a*T))/(z-exp(-a*T))^3

>> f1=iztrans(F) f1 =

T^2*(1/exp(a*T))^n*n^2 (3)

>> syms a k T;f=(a*k*T-1+exp(-a*k*T))/a;F=ztrans(f) F =

1/a*(a*T*z/(z-1)^2-z/(z-1)+z/exp(-a*T)/(z/exp(-a*T)-1))

>> iztrans(F) ans =

((1/exp(a*T))^n+a*T*n-1)/a 第五题 (1)

>> syms x;x1=solve('exp(-(x+1)^2+pi/2)*sin(5*x+2)') x1 = -2/5

>> subs('exp(-(x+1)^2+pi/2)*sin(5*x+2)',x,x1)

ans = 0

>> f=inline('exp(-(x+1).^2+pi/2).*sin(5*x+2)','x'); >> x2=fsolve(f,0)

Optimization terminated: first-order optimality is less than options.TolFun. x2 =

0.2283

>> subs('exp(-(x+1)^2+pi/2)*sin(5*x+2)',x,x2)

ans =

4.7509e-008 (2)

>> syms x;y1=solve('(x^2+y^2+x*y)*exp(-x^2-y^2-x*y)=0','y') y1 =

(-1/2+1/2*i*3^(1/2))*x (-1/2-1/2*i*3^(1/2))*x

>> y2=simple(subs('(x^2+y^2+x*y)*exp(-x^2-y*2-x*y)','y',y1)) y2 = 0 0 第六题

>> syms x c;y=int((exp(x)-c*x)^2,x,0,1) y =

1/2*exp(1)^2+1/3*c^2-1/2-2*c

>> edit

function y=f(c)

y=1/2*exp(1)^2+1/3*c-1/2-2*c

>> x=fminsearch('f',0) x =

3.1691e+026

>> ezplot(y,[0,5])

第七题 >> edit

function y=f1(x)

y=exp(x(1))*(4*x(1)^2+2*x(2)^2+4*x(1)*x(2)+2*x(2)+1) function [c,ce]=f2(x); ce=[];

c=[x(1)+x(2);x(1)*x(2)-x(1)-x(2)+1.5;-10-x(1)*x(2)];

>> edit

>> A=[];B=[];Aeq=[];Beq=[];xm=[-10;-10];xM=[10;10]; >> x0=(xm+xM)/2;

>> ff=optimset;ff.TolX=1e-10;ff.TolFun=1e-20; >> x=fmincon('f1',x0,A,B,Aeq,Beq,xm,xM,'f2',ff)

Maximum number of function evaluations exceeded; increase OPTIONS.MaxFunEvals. x =

0.4195 0.4195 >> i=1;x=x0; >> while (1)

[x,a,b]=fmincon('f1',x,A,B,Aeq,Beq,xm,xM,'f2',ff); if b>0,break;end i=i+1; end >> x,i x =

1.1825 -1.7398 i =

5 第八题

function y=f3 (x)

y=-(592*x(1)+381*x(2)+273*x(3)+55*x(4)+48*x(5)+37*x(6)+23*x(7)); function [c,ceq]=f4(x) c=[];ceq=[];

>> A=[3534,2356,1767,589,528,451,304];B=119567; intlist=ones(7,1);Aeq=[];Beq=[];

xm=zeros(7,1);xM=inf*ones(7,1);x0=zeros(7,1);

ff=optimset;ff.TolFun=1e-6;ff.TolX=1e-6;ff.TolCon=1e-20; ff.MaxSQPIter=1000;settings=[0];

ix=(intlist==1);xm(ix)=ceil(xm(ix));xM(ix)=floor(xM(ix));

[errmsg,f,x]=bnb20('f3',x0,intlist,xm,xM,A,B,Aeq,Beq,f4, settings,ff) if length(errmsg)==0,x=round(x),end x =

32 2 1 0

0 0 0

第九题 >> syms x

>> y=dsolve('D2y-(2-1/x)*Dy+(1-1/x)*y=x^2*exp(-5*x)','x') y =

exp(x)*C2+exp(x)*log(x)*C1+1/216*Ei(1,6*x)*exp(x)+11/1296*exp(-5*x)+5/216*exp(-5*x)*x+1/36*x^2*exp(-5*x)

>> syms x

>> y=dsolve('D2y-(2-1/x)*Dy+(1-1/x)*y=x^2*exp(-5*x)','y(1)=sym(pi)','y(sym(pi))=1','x') y =

-1/1296*exp(x)*(-1296*sym(pi)*exp(5)+6*exp(6)*Ei(1,6)+77)/exp(1)/exp(5)-1/1296*exp(x)*log(x)*(-1296*exp(1)*exp(5)+1296*exp(sym(pi))*sym(pi)*exp(5)-6*exp(sym(pi))*exp(6)*Ei(1,6)-77*exp(sym(pi))+6*exp(-5*sym(pi))*exp(6*sym(pi))*Ei(1,6*sym(pi))*exp(1)*exp(5)+11*exp(-5*sym(pi))*exp(1)*exp(5)+30*exp(-5*sym(pi))*sym(pi)*exp(1)*exp(5)+36*exp(-5*sym(pi))*sym(pi)^2*exp(1)*exp(5))/exp(sym(pi))/log(sym(pi))/exp(1)/exp(5)+1/1296*(6*exp(6*x)*Ei(1,6*x)+11+30*x+36*x^2)*exp(-5*x) 第十题 >> syms t;

>> x=dsolve('D2x+2*t*Dx+t^2*x=t+1') x =

exp(t-1/2*t^2)*C2+exp(-t-1/2*t^2)*C1-1/2*i*pi^(1/2)*2^(1/2)*erf(1/2*i*2^(1/2)*(-1+t))*exp(-1/2+t-1/2*t^2)

>> syms x

>> y=dsolve('Dy+2*x*y=x*exp(-x^2)','x') y =

1/2*(x^2+2*C1)*exp(-x^2)

第十一题