Matlab实验报告Word文件下载.docx
《Matlab实验报告Word文件下载.docx》由会员分享,可在线阅读,更多相关《Matlab实验报告Word文件下载.docx(21页珍藏版)》请在冰豆网上搜索。
![Matlab实验报告Word文件下载.docx](https://file1.bdocx.com/fileroot1/2022-12/12/ae5c447a-8cf1-46d6-b2a2-232886e50b74/ae5c447a-8cf1-46d6-b2a2-232886e50b741.gif)
ch='
ABcdefGHd'
k=find(ch>
='
A'
&
ch<
Z'
),ch(k)=[]
1.5
a11=input('
a11='
),a12=input('
a12='
),
a21=input('
a21='
),a22=input('
a22='
A=[a11,a12;
a21,a22],
DA=det(A),IA=inv(A),EA=eig(A)
实验二M函数与M文件的编写与应用
2.1
n=100;
a=ones(1,n);
fori=3:
n
a(i)=a(i-1)+a(i-2);
ifa(i)>
10000
a(i),
break;
end;
end,i
2.3
functiony=ff(t)
y1=exp(-t/3);
y2=exp(-t/3).*sin(3*t);
y=[y1;
y2]
实验三选择与循环结构程序设计
3.1
forn=1:
100
f(n)=1./(2*n-1)
y=sum(f)
ify>
=3
my=y-f(n)
mn=n-1
break
end
end
my
Mn
3.3
per=input('
输入成绩:
'
)
switchfloor(per/10)
case9
grade='
case8
B'
case7
C'
case6
D'
casenum2cell(0:
5)
E'
otherwise
ifper==100
elsegrade='
error'
实验四绘图函数的应用
4.1
0.05:
2*pi;
plot(t,sin(t),'
r-.o'
t,cos(t),'
m-s'
legend('
sinx'
'
cosx'
4)
axis([02*pi-22])
4.3
x=0:
0.1:
100;
y=log10(x);
subplot(311),loglog(x,y)
grid
title('
logloggraph'
subplot(312),semilogx(x,y)
semilogxgraph'
subplot(313),semilogy(x,y)
semilogygraph'
4.5
x=[-2:
0.02:
2];
y=1.1*sign(x).*(abs(x)>
1.1)+x.*(abs(x)<
=1.1);
plot(x,y)
实验五数值工具箱与符号工具箱的应用
5.1
h=6:
2:
18;
t1=[18202225302824];
t2=[15192428343230];
h1=6.5:
17.5;
t11=interp1(h,t1,h1,'
spline'
t22=interp1(h,t2,h1,'
5.3
clear
fxy=sym('
log(x+exp(y))/sqrt(x^2+y^2)'
result=limit(limit(fxy,'
x'
1),'
y'
0)
5.5
symsaxty1y2
y1=sqrt(a+t)
y2=int(y1,t,x,x^2);
diff(y2,x)
结果:
5.7
symsxyz
f=x+2*y-2*sqrt(x*y*z);
fx=diff(f,x);
fy=diff(f,y);
fz=diff(f,z);
zx=-fx/fz
zy=-fy/fz
实验六Simulink仿真应用
例5.6
(1)
(2)
%exm5_6.m
clf;
holdon
xx=[-2,1;
-1,1;
0,1;
1,1;
1,0;
1,-1;
1,-2];
nxx=size(xx,1);
fork=1:
nxx
opts=simset('
initialstate'
[xx(k,1),xx(k,2)]);
[t,x,y]=sim('
exm5_5'
10,opts);
plot(x(:
1),x(:
2));
xlabel('
x1'
);
ylabel('
x2'
),grid,holdoff
(3)
(4)
function[DX1,DX2,DP]=portraitzzy(x1,x2,h)
%PORTRAITZZY
%x1,x2
%h
%DX1,DX2
%DP
opts=simset('
solver'
ode5'
fixedstep'
h);
n=length(x1);
X1=zeros(n,n);
X2=X1;
forii=1:
n;
forjj=1:
opts=simset(opts,'
[x1(ii),x2(jj)]);
h,opts);
dx1=x(2,1)-x1(ii);
dx2=x(2,2)-x2(jj);
L=sqrt(dx1^2+dx2^2);
Z(jj,ii)=L
ifL>
1.e-10
DX1(jj,ii)=dx1/L;
DX2(jj,ii)=dx2/L;
DP=Z/h;
(5)
h=0.01;
x1=-2.5:
0.25:
2.5;
x2=x1;
k=0.15;
[X1,X2,Z]=portraitzzy(x1,x2,h);
quiver(x1,x2,k*X1,k*X2,0)
),ylabel('
(6)
surfc(x1,x2,Z),view([18,32]),xlabel('
(7)
xa=trim('
[-1,-2]'
xb=trim('
[1,2]'
(8)
Axa=linmod('
xa);
eig_Axa=(eig(Axa.a))'
Axb=linmod('
xb);
eig_Axb=(eig(Axb.a))'
实验七线性系统分析与设计
7.1
num=[0.00010.02181.04369.3599];
den=[0.00060.02680.63656.2711];
sys=tf(num,den);
sys1=ss(sys)
sys2=zpk(sys)
7.3
clc
closeall
num=[00281282];
den=[151010510];
sys=tf(num,den)
bode(sys)
figure
nichols(sys),
nyquist(sys)