工大Matlab实验报告Word文档格式.docx
- 文档编号:18656042
- 上传时间:2022-12-31
- 格式:DOCX
- 页数:25
- 大小:66.13KB
工大Matlab实验报告Word文档格式.docx
《工大Matlab实验报告Word文档格式.docx》由会员分享,可在线阅读,更多相关《工大Matlab实验报告Word文档格式.docx(25页珍藏版)》请在冰豆网上搜索。
123
456
789
a=[1:
3;
4:
6;
7:
9]
a=[linspace(1,3,3);
linspace(4,6,3);
linspace(7,9,3)]
a=ones(3)
111
a(1,:
)=[123];
a(2,:
)=[456]
b=a(3:
6)
1251
b
(1)=[]
251
2.矩阵的运算
(1).解线性方程组
a=[2-302;
1521;
3-11-1;
4122]
2-302
1521
3-11-1
4122
b=[8;
2;
7;
12];
x=a\b
x=
3.0000
0.0000
-1.0000
1.0000
(2).解矩阵方程
A=[1/300;
01/40;
001/7];
B=inv(A)*inv(inv(A)-eye(3))*6*A
B=
3.000000
02.00000
001.0000
(3).计算特征值和特征向量,验证它们之间的关系
x=[120;
25-1;
410-1]
120
25-1
410-1
[v,d]=eig(x)
v=
-0.2440-0.91070.4472
-0.33330.33330.0000
-0.9107-0.24400.8944
3.732100
00.26790
x*v
ans=
-0.9107-0.24400.4472
-1.24400.08930.0000
-3.3987-0.06540.8944
x*d
3.73210.53590
7.46411.3397-1.0000
14.92822.6795-1.0000
3.多项式的运算
(1).表达式G(x)=(x-4)(x+5)(x^2-6x+9)
p1=[1-4]
p1=
1-4
p2=[15]
p2=
15
p3=[1-69]
p3=
1-69
G=conv(p1,p2)
G=
11-20
G=conv(G,p3)
1-5-17129-180
x=0:
20;
y=polyval(G,x)
Columns1through8
-180-72-140040198576
Columns9through16
130025204410716811016162002299031680
Columns17through21
42588560567245092160115600
x0=roots(G)
x0=
-5.0000
4.0000
deconv(deconv(G,p3),p2)
1-4
(2).多项式拟合与插值
G(x)=x^4-5x^3-17x^2+129x-180
G=[1-5-17129-180];
y=polyval(G,x);
y0=0.1*randn(1,21)
y0=
Columns1through10
0.05380.1834-0.22590.08620.0319-0.1308-0.04340.03430.35780.2769
Columns11through20
-0.13500.30350.0725-0.00630.0715-0.0205-0.01240.14900.14090.1417
Column21
0.0671
y1=y+y0
y1=
1.0e+05*
-0.0018-0.0007-0.00010.00000.00000.00040.00200.00580.01300.0252
0.04410.07170.11020.16200.22990.31680.42590.56060.72450.9216
1.1560
G1=polyfit(x,y1,4)
G1=
1.0000-5.0019-16.9766128.9086-179.9123
实验三MATLAB的符号计算
f=sym('
sin(x)'
)
f=
sin(x)
g=sym('
y/exp(-2*t)'
g=
y*exp(2*t)
symsxyt
f=sym(sin(x))
g=sym(y/exp(-2*t))
symvar(g)
[t,y]
symvar(g,1)
y
findsym(g,2)
y,t
10;
y=subs(f,x)
[0,sin
(1),sin
(2),sin(3),sin(4),sin(5),sin(6),sin(7),sin(8),sin(9),sin(10)]
f1=subs(f,'
5'
f1=
sin(5)
y1=double(f1)
-0.9589
y2=eval(f1)
y2=
digits
Digits=32
vpa(f1)
-0.95892427466313846889315440615599
VPA(F1,10)
Undefinedfunctionorvariable'
F1'
.
Didyoumean:
vpa(f1,10)
-0.9589242747
sn(x)'
);
finverse(f)
Warning:
Functionalinversecannotbefound.
InD:
\ProgramFiles\MATLAB\R2013a\toolbox\symbolic\symbolic\symengine.p>
symengineat56
Insym.sym>
sym.privBinaryOpat1693
Insym.finverseat31
[emptysym]
finverse(g,'
t'
log(t/y)/2
compose(g,'
t*exp(2*t)
compose(f,g)
sn(y*exp(2*t))
compose(f,g,'
z'
sn(z*exp(2*t))
diff(f)
diff(sn(x),x)
cos(x)
1.00000.5403-0.4161-0.9900-0.65360.28370.96020.7539
Columns9through11
-0.1455-0.9111-0.8391
diff(g)
exp(2*t)
diff(g,'
2*y*exp(2*t)
symstx
limit((sin(x+t)-sin(x)/t,t,0)
|
Error:
Expressionorstatementisincorrect--possiblyunbalanced(,{,or[.
limit((sin(x+t)-sin(x))/t,t,0)
cos(x)
int(f)
Explicitintegralcouldnotbefound.
int(sn(x),x)
sin(x)"
AMATLABstringconstantisnotterminatedproperly.
-cos(x)
int(g)
(y^2*exp(2*t))/2
int(g,'
(y*exp(2*t))/2
0,10)
(y*(exp(20)-1))/2
x^2+3*x+2'
x^2+3*x+2
x^3-1'
x^3-1
f+g
x^3+x^2+3*x+1
f~=g
x^2+3*x+2~=x^3-1
pretty(f)
2
x+3x+2
f1=horner(f)
x*(x+3)+2
f2=factor(f1)
f2=
(x+2)*(x+1)
somple(g)
Undefinedfunction'
somple'
forinputargumentsoftype'
sym'
simple(g)
simplify:
radsimp:
simplify(Steps=100):
combine(sincos):
combine(sinhcosh):
combine(ln):
factor:
(x-1)*(x^2+x+1)
expand:
combine:
rewrite(exp):
rewrite(sincos):
rewrite(sinhcosh):
rewrite(tan):
mwcos2sin:
collect(x):
h=sym2poly(f)
h=
132
f=poly2sym(h)
A=sym('
[xx^2;
2*xcos(2*t)]'
A=
[x,x^2]
[2*x,cos(2*t)]
A.'
[x,2*x]
[x^2,cos(2*t)]
det(A)
-2*x^3+cos(2*t)*x
diff(A)
[1,2*x]
[2,0]
eq1=sym('
2*x1-3*x2+2*x4=8'
eq1=
2*x1-3*x2+2*x4==8
eq2=('
x1+5*x2+2*x3+x4=2'
eq3=('
3*x1-x2+x3-x4=7'
eq2=sym('
eq3=sym('
eq3=
3*x1-x2+x3-x4==7
eq4=sym('
4*x1+x2+2*x3+2*x4=12'
[x1,x2,x3,x4]=solve(eq1,eq2,eq3,eq4)
x1=
3
x2=
x3=
-1
x4=
1
[y,z]=dsolve('
Dy-z=cos(x),Dz+y=1'
'
x'
sin(x)*(C4+(sin(x)*(sin(x)+2))/2)+cos(x)*(C5+x/2+2*cos(x/2)^3*sin(x/2)+2*cos(x/2)^2-cos(x/2)*sin(x/2))
z=
cos(x)*(C4+(sin(x)*(sin(x)+2))/2)-sin(x)*(C5+x/2+2*cos(x/2)^3*sin(x/2)+2*cos(x/2)^2-cos(x/2)*sin(x/2))
实验四MATLAB的计算可视化和GUI设计
1.绘制二维曲线
窗口1:
y=sin(2πt),t∈[0,2];
窗口2:
y=e^(-t),y=e^(-2t),y=e^(-3t),t∈[0,2];
窗口3:
矩形脉冲:
宽度为1,高度为2,开始时间为1;
窗口4:
单位圆
subplot(2,2,1)
t1=0:
0.1:
y1=sin(2*pi*t1);
plot(t1,y1)
title('
y=sin(2\pit)'
subplot(2,2,2)
t2=0:
y2=[exp(-t2);
exp(-2*t2);
exp(-3*t2)];
plot(t2,y2)
axis([02-0.21.2]);
y=e-t,y=e-2t,y=e-3t'
subplot(2,2,3);
t3=[0112234];
y3=[0022000];
plot(t3,y3);
axis([04-0.53]);
脉冲信号'
subplot(2,2,4);
t4=0:
2*pi;
plot(sin(t4),cos(t4))
axis([-1.21.2-1.21.2]);
axisequal;
圆'
2.绘制多条二阶系统时域曲线和三维图形
二阶系统的时域响应为:
y=1-1/(sqrt(1-zeta^2))*e^(-zetax)*sin(sqrt(1-zeta^2)x+a*cos(zeta))
zeta=0
zeta=
0
y1=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
plot(x,y1)
zeta=0.3;
y2=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
holdon
plot(x,y2,'
r:
'
zeta=0.5;
y3=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
plot(x,y3,'
g*'
zeta=0.707;
y4=1-1/sqrt(1-zeta^2)*exp(-zeta*x).*sin(sqrt(1-zeta^2)*x+acos(zeta));
plot(x,y4,'
m--'
二阶系统曲线'
legend('
\zeta=0'
\zeta=0.3'
\zeta=0.5'
zeta=0.707'
gridon
gtext('
\zeta=0.707'
ginput(3)
4.58531.0906
7.90321.0088
14.21661.0146
3.特殊图形
(1).绘制条形图
0.3:
y=sin(x);
bar(x,y,0.5)
axis([0,2*pi,-1.2,1.2])
(2).绘制实心图
fill(x,y,'
r'
(3).绘制阶梯图
subplot(2,2,3)
stairs(x,y)
(4).绘制火柴杆图
subplot(2,2,4)
stem(x,y)
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Matlab 实验 报告
![提示](https://static.bdocx.com/images/bang_tan.gif)