东北大学matlab上机作业1文档格式.docx
《东北大学matlab上机作业1文档格式.docx》由会员分享,可在线阅读,更多相关《东北大学matlab上机作业1文档格式.docx(30页珍藏版)》请在冰豆网上搜索。
234100
324100
000005
3、
A=magic(8)
642361606757
955541213515016
1747462021434224
4026273736303133
3234352928383925
4123224445191848
4915145253111056
858595462631
B=A(2:
2:
end,:
)
4、
sum(sym
(2).^[0:
63])
ans=
184********709551615
5、
t=[-1:
0.03:
-0.25,-0.249:
0.007:
0.249,0.25:
0.4:
1];
y=sin(1./t);
plot(t,y)
t=[-pi:
0.05:
-1.8,-1.799:
0.001:
-1.2,-1.2:
0.005:
1.2,1.201:
1.8,1.81:
pi];
y=sin(tan(t))-tan(sin(t));
6、
三维图xx=[-2:
.1:
-1.2,-1.1:
0.02:
-0.9,-0.8:
0.1:
0.8,0.9:
1.1,1.2:
2];
yy=[-1:
-0.2,-0.1:
0.1,0.2:
[x,y]=meshgrid(xx,yy);
z=1./(sqrt((1-x).^2+y.^2))+1./(sqrt((1+x).^2+y.^2));
surf(x,y,z),shadingflat;
zlim([0,15])
三视图
[x,y]=meshgrid(-2:
2);
subplot(221),surf(x,y,z),view(0,90);
subplot(222),surf(x,y,z),view(90,0);
subplot(223),surf(x,y,z),view(0,0);
7、
(1)symsx;
f=(3^x+9^x)^(1/x);
L=limit(f,x,inf)
L=
9
(2)symsxy;
f=(x*y)/(sqrt(x*y+1)-1);
L=limit(limit(f,x,0),y,0)
2
(3)Symsxy;
f=(1-cos(x^2+y^2))/((x^2+y^2)*exp(x^2+y^2));
8、
(1)symst;
x=log(cos(t));
y=cos(t)-t*sin(t);
f1=diff(y,t)/diff(x,t)
f1=
-(-2*sin(t)-t*cos(t))/sin(t)*cos(t)
(2)
symst;
f2=diff(y,t,2)/diff(x,t,2);
subs(f2,t,sym(pi)/3)
3/8-1/24*pi*3^(1/2)
9、
symsxyt;
f=int(exp(-t^2),t,0,x*y);
I=simple(x/y*diff(f,x,2)-2*diff(diff(f,x),y)+diff(f,y,2))
I=
-2*exp(-x^2*y^2)*(-x^2*y^2+1+x^3*y)
10、
(1)symsmn;
limit(symsum(1/((2*m)^2-1),m,1,n),n,inf)
1/2
(2)symsmn;
limit(symsum(n*(1/(n^2+m*pi)),m,1,n),n,inf)
1
11、
(1)symsat;
symsapositive;
x=a*(cos(t)+t*sin(t));
y=a*(sin(t)-t*cos(t));
I=simple(int((x^2+y^2)*sqrt(diff(x,t)^2+diff(y,t)^2),t,0,2*pi))
(2*pi^2+4*pi^4)*a^3
(2)symsxyabct;
x=c*cos(t)/a;
y=c*sin(t)/b;
P=y*x^3+exp(y);
Q=x*y^3+x*exp(y)-2*y;
ds=[diff(x,t);
diff(y,t)];
I=int([P,Q]*ds,t,0,pi)
-2/15*c*(-2*c^4+15*b^4)/b^4/a
12、
functionA=vander(v)
n=length(v);
v=v(:
);
A=sym(ones(n));
forj=n-1:
-1:
1,A(:
j)=v.*A(:
j+1);
end
symsabcde;
A=vander([abcde]);
B=simple(det(A))
(c-d)*(b-d)*(b-c)*(a-d)*(a-c)*(a-b)*(-d+e)*(e-c)*(e-b)*(e-a)
13.
A=[-2,0.5,-0.5,0.5;
0,-1.5,0.5,-0.5;
2,0.5,-4.5,0.5;
2,1,-2,-2];
[V,J]=jordan(sym(A))
V=
[0,1/2,1/2,-1/4]
[0,0,1/2,1]
[1/4,1/2,1/2,-1/4]
[1/4,1/2,1,-1/4]
J=
[-4,0,0,0]
[0,-2,1,0]
[0,0,-2,1]
[0,0,0,-2]
14、
数值解
A=[3,-6,-4,0,5;
1,4,2,-2,4;
-6,3,-6,7,3;
-13,10,0,-11,0;
0,4,0,3,4];
B=[3,-2,1;
-2,-9,2;
-2,-1,9];
C=[-2,1,-1;
4,1,2;
5,-6,1;
6,-4,-4;
-6,6,-3];
X=lyap(A,B,C),norm(A*X+X*B+C)
X=
-4.0569-14.51281.5653
0.035625.0743-2.7408
9.488625.9323-4.4177
2.696921.6450-2.8851
7.722931.9100-3.7634
2.7917e-013
解析解
functionX=lyap(A,B,C)
ifnargin==2,C=B;
B=A'
;
end
[nr,nc]=size(C);
A0=kron(A,eye(nc))+kron(eye(nr),B'
try
C1=C'
x0=-inv(A0)*C1(:
X=reshape(x0,nc,nr)'
catch,error('
singularmatrixfound.'
),end
C=-[-2,1,-1;
X=lyap(sym(A),B,C),norm(double(A*X+X*B+C))
[434641749950/107136516451,4664546747350/321409549353,-503105815912/321409549353]
[-3809507498/107136516451,-8059112319373/321409549353,880921527508/321409549353]
[-1016580400173/107136516451,-8334897743767/321409549353,1419901706449/321409549353]
[-288938859984/107136516451,-6956912657222/321409549353,927293592476/321409549353]
[-827401644798/107136516451,-10256166034813/321409549353,1209595497577/321409549353]
0
15、
functionF=funm(A,fun,x)
[V,J]=jordan(A);
v1=[0,diag(J,1)'
];
v2=[find(v1==0),length(v1)+1];
fori=1:
length(v2)-1
v_lambda(i)=J(v2(i),v2(i));
v_n(i)=v2(i+1)-v2(i);
m=length(v_lambda);
F=sym([]);
m
J1=J(v2(i):
v2(i)+v_n(i)-1,v2(i):
v2(i)+v_n(i)-1);
fJ=funJ(J1,fun,x);
F=diagm(F,fJ);
F=V*F*inv(V);
functionfJ=funJ(J,fun,x)
lam=J(1,1);
f1=fun;
fJ=subs(fun,x,lam)*eye(size(J));
H=diag(diag(J,1),1);
H1=H;
fori=2:
length(J)
f1=diff(f1,x);
a1=subs(f1,x,lam);
fJ=fJ+a1*H1;
H1=H1*H/i;
functionA=diagm(A1,A2)
A=A1;
[n,m]=size(A);
[n1,m1]=size(A2);
A(n+1:
n+n1,m+1:
m+m1)=A2;
symsxt;
A=[-4.5,0,0.5,-1.5;
-0.5,-4,0.5,-0.5;
1.5,1,-2.5,1.5;
0,-1,-1,-3];
A=sym(A);
B=expm(A*t),
C=funm(A,sin(x*t),x),D=funm(A,exp(x*t)*sin(x^2*exp(x*t)*t),x)
[1/2*exp(-3*t)-1/2*t*exp(-3*t)+1/2*exp(-5*t)+1/2*t^2*exp(-3*t),1/2*exp(-5*t)-1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*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))^2+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(2*t*exp(-3*t)-12*t^2*exp(-3*t)+9*t^3*exp(-3*t))-1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))-1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*t*exp(-3*t)),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+t*exp(-3*t)*sin(9*t*exp(-3*t))+exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*t*exp(-3*t)),1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))+1/2*t^2*exp(-3*t)*sin(9*t*exp(-3*t))+t*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))^2+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(2*t*exp(-3*t)-12*t^2*exp(-3*t)+9*t^3*exp(-3*t)),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)-1/2*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*t^2*exp(-3*t)*sin(9*t*exp(-3*t))+t*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))^2+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(2*t*exp(-3*t)-12*t^2*exp(-3*t)+9*t^3*exp(-3*t))-1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))-1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))]
[1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*t*exp(-3*t)),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*exp(-3*t)*sin(9*t*exp(-3*t)),1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t)),1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))-1/2*exp(-3*t)*sin(9*t*exp(-3*t))]
[-1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*t*exp(-3*t)),-1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*exp(-3*t)*sin(9*t*exp(-3*t)),exp(-3*t)*sin(9*t*exp(-3*t))+1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t)),-1/2*exp(-5*t)*sin(25*exp(-5*t)*t)+1/2*t*exp(-3*t)*sin(9*t*exp(-3*t))+1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*t*exp(-3*t))]
[-1/2*t^2*exp(-3*t)*sin(9*t*exp(-3*t))-t*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))^2-1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(2*t*exp(-3*t)-12*t^2*exp(-3*t)+9*t^3*exp(-3*t)),-t*exp(-3*t)*sin(9*t*exp(-3*t))-exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t)),-t*exp(-3*t)*sin(9*t*exp(-3*t))-exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))-1/2*t^2*exp(-3*t)*sin(9*t*exp(-3*t))-t*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))^2-1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(2*t*exp(-3*t)-12*t^2*exp(-3*t)+9*t^3*exp(-3*t)),exp(-3*t)*sin(9*t*exp(-3*t))-1/2*t^2*exp(-3*t)*sin(9*t*exp(-3*t))-t*exp(-3*t)*cos(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))+1/2*exp(-3*t)*sin(9*t*exp(-3*t))*(-6*t*exp(-3*t)+9*t^2*exp(-3*t))^2-1/2*exp(-3*t)*cos(9*t*exp(-3*t))*(2*t*exp(-3*t)-12*t^2*exp(-3*t)+9*t^3*exp(-3*t))]
第二部分
(1)symstalpha;
f=sin(alpha*t)/t;
F=laplace(f)
F=
atan(alpha/s)
(2)symstalpha;
f=t^5*sin(alpha*t);
F=la