北方工业大学matlab期末考试复习Word文档格式.docx

上传人:b****2 文档编号:5767196 上传时间:2023-05-05 格式:DOCX 页数:25 大小:89.05KB
下载 相关 举报
北方工业大学matlab期末考试复习Word文档格式.docx_第1页
第1页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第2页
第2页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第3页
第3页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第4页
第4页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第5页
第5页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第6页
第6页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第7页
第7页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第8页
第8页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第9页
第9页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第10页
第10页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第11页
第11页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第12页
第12页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第13页
第13页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第14页
第14页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第15页
第15页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第16页
第16页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第17页
第17页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第18页
第18页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第19页
第19页 / 共25页
北方工业大学matlab期末考试复习Word文档格式.docx_第20页
第20页 / 共25页
亲,该文档总共25页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

北方工业大学matlab期末考试复习Word文档格式.docx

《北方工业大学matlab期末考试复习Word文档格式.docx》由会员分享,可在线阅读,更多相关《北方工业大学matlab期末考试复习Word文档格式.docx(25页珍藏版)》请在冰点文库上搜索。

北方工业大学matlab期末考试复习Word文档格式.docx

789]

A=

123

456

789

A(1,1)

1

A(1,:

A(1,[13])

13

A(:

2)

2

5

8

逗号前边的是行,后边的是列,用:

表示提取所有。

2.怎么使用:

步距确定

t=1:

1:

10

t=

12345678910

涉及步距的变化

linspace的使用要多少个点是确定的

linspace(0,2*pi,5)

11.57083.14164.71246.2832

3矩阵的除

n=[987;

m/n

Warning:

Matrixissingulartoworkingprecision.

NaNNaNNaN

NaN-InfInf

m./n

0.11110.25000.4286

0.66671.00001.5000

2.33334.00009.0000

4.矩阵的加(减)

m+n

101010

m.+n

m.+n|

Error:

UnexpectedMATLABoperator.

5.A=[123];

A.^2

149

6.初等函数:

abs()绝对值

sqrt()开平方

exp(x)e的x次方

log(x)以e为底的对数

log10(x)以10为底的对数

asin,acos:

反三角函数

6.二维绘图:

X=0:

pi/10:

2*pi;

y=sin(x)

plot(x,y)

axis([010-55])

xlabel('

ylabel('

y=mx+c'

title('

Myfirstfigure'

plot(x,y,’r:

+’)

red,yellow,blue,green,white,cyan,magenta,black.

Linestyles:

-,--,:

-.

Markertypes(标记类型):

+,o,*,x,square(方框),diamond(菱形),^,v,<

>

pentagram(五角星),hexagram(六角星)

slope(斜率)intercept(截距)y=0.5*x-2vector(矢量

x=tsin(t)

y=(t-1)/(t+1)

z=sin(t2)/t2

10;

x=t.*sin(t);

z=sin(t.^2)./t.^2;

y=(t-1)./(t+1);

plot(t,x,t,y,t,z)

legend('

'

y'

z'

legened(图例注释)

7.求和:

t=1:

5

sum(t)

12345

sum(A)

121518

列向量相加

8.矩阵的运算、

转置:

几行几列:

A=[123;

788];

size(A)

33

9.Scriptfile(脚本文件)

命名:

NoChinesename

刘瑛.m

Thefirstcharactershouldnotbenumber.(首位不能是数字)

123.m1.m1a.m

No+,-,*,/including(不能包含这些符号)

my-assignment.m(错误)

画圆的m文件以及input的使用:

(user_entry=input('

prompt'

s'

)加s表示当做字符串。

否则当做数字来处理

functioncircle(R)

R=input('

Entertheradiusofthecircle:

'

)%输入半径

alpha=0:

pi/50:

x=R*cos(alpha);

y=R*sin(alpha);

plot(x,y,'

-'

axisequal

保存路径:

circle.m

10.如何控制线宽:

plot(x,y,'

r'

LineWidth'

4)

11.定义:

行列式determinant

矩阵的秩rank

逆矩阵matrixinverse

特征根、特征向量Eigenvaluesandeigenvectors

矩阵的最简形Reducedrowechelonform

线性方程组有解的条件

12.Youhavewrittenascriptfilecircle.mandtypeincircleincommandwindowtorunit.butthesystemsays“?

circle'

.”what’sthemostpossibleproblem?

(你写了一个脚本文件,在圆型圆。

在命令窗口运行它。

但系统说”?

定义函数或变量圆圈。

”什么是最可能的问题?

保存路径的问题

13.解线性方程组:

5x=3y-2z+10

8y+4z=3x+30

2x+4y-9z=9

5x-3y+2z=10

-3x+8y+4z=30

5-3210

A=-384b=30

24-99

X=A\b

A=[5-32;

-384;

24-9]

b=[10;

30;

9]

判断方程组是否有解:

n元线性方程组Ax=b

(1)无解的充分条件是R(A)<

R(A,b)

(2)有唯一解的充要条件是R(A)=R(A,b)=n

(3)有无限多解的充要条件是R(A)=R(A,b)<

n

过程:

求秩:

rank(A)

建立增广矩阵:

[AB],求增广矩阵秩,rank([AB])

14.

最简形:

rref(x)就是通过一系列的初等行列变换后变成的左上角部分是个单位矩阵,除了左上角单位阵部分的其它地方的元素全部为0的矩阵就是原矩阵的最简形矩阵

求矩阵的值:

det(A)

D1=12

34

A1=[1,2;

3,4]

D1=det(A1)ans=-2

求逆矩阵:

inv(A)

求特征根特征向量:

[vector,lamda]=eig(A)

划三角矩阵[L,U]=lu(A)L下三角U上三角

求正交矩阵[Q,R]=qr(A)Q是正交矩阵R上三角

14.Linearoptimization线性优化

Non-linearoptimization非线性优化

x=linprog(f,A,b,Aeq,beq,lb,ub)

Linprog求函数f在何处有最小值

x:

optimizedvector.最优化向量

Ab:

不等式约束,inequalityconstraints如A*x<

=b

Aeq,beq:

等式约束equalityconstraints如Aeq*x=beq

lb,ub:

上下限,lowerandupperbounds如lb<

=x<

=ub

Target:

maxf=70x1+120x2

constraints:

9x1+4x2≤3600

4x1+5x2≤2000

3x1+10x2≤3000

x1,x2≥0

f=[-70-120];

A=[94;

45;

310];

b=[3600;

2000;

3000];

lb=[00];

ub=[];

[x,fval,exitflag]=linprog(f,A,b,[],[],lb,ub)

maxf=-fval

[x,fval,exitflag]=linprog(f,A,b,Aeq,beq,lb,ub)

optimizedvector.最优化向量

Fval:

函数在x处的值;

thevalueoftheobjectivefunctionfun

Exitflag:

描述函数计算的退出条件:

若为正值,表示目标函数收敛于解x处;

若为负值,表示目标函数不收敛;

若为零值,表示已经达到函数评价或迭代的最大次数。

15.曲线拟合(Curvefittingandinterpolation曲线拟合合插补)

Polyfit的使用用多项式进行拟合,得到相应的多项式的系数,A=polyfit(x,y,n)n是多项式的次数

y=polyval(a,x)把x代入多项式a中,求值

多项式:

polynomial

Interpolation,插补yi=interp1(x,y,xi,method);

方法:

linear线性nearest最近插补spline样条pchip导数

hours=1:

12;

temps=[589152529313022252724];

t1=interp1(hours,temps,4.5)

t2=interp1(hours,temps,4.5,’linear’)

16.NumericalIntegration(Quadrature)数值积分

quad(F,a,b)

F=inline('

x.^2-3*x'

);

a=0;

b=l0;

quad(F,a,b)

用积分求圆的面积:

Calculatetheareaofaunitcircle.

x2+y2=1

y=sqrt(1-x2)

f=inline('

sqrt(1-x.^2)'

quad(f,0,2*pi)

Doubleintegration重积分

dblquad(f,xmin,xmax,ymin,ymax)

1-6*x.^2.*y'

17.DataAnalysisandstatistics数据分析和统计

mean均值

median中值

std均方差(standarddeviation)

maxminsort数据由小到大排列

size看矩阵式几行几列

18.求根

x5-3x3+x2-9=0

C=[10-310-9]

roots(C)

x=fzero(f,x0)x0是估计的跟的值

f(x)=sin(x)-ex+5=0

sin(x)-exp(x)+5'

ezplot(f),grid

%solveitwithainitialguess

fzero(f,2)

19.求极值x=fminbnd(f,x1,x2)

极小值:

f(x)=0.5*x.^2-10*sin(x).^2

0.5*x.^2-10*sin(x).^2'

ezplot(f),grid

holdon

x1=fminbnd(f,-6,-4)

y1=f(x1)

plot(x1,y1,'

ro'

holdoff

极大值:

f_neg=inline('

-(0.5*x.^2-10*sin(x).^2)'

x_max=fminbnd(f_neg,-4,-2)

y_max=f(x_max)

plot(x_max,y_max,'

20.function

求直角三角形斜边长:

functionr=get_hypo(a,b)

r=sqrt(a.^2+b.^2)

注意文件名应该与函数名保持一致,运行时输入含有指定值的函数

画圆:

function[x,y]=circlefn(r);

theta=linspace(0,2*pi,100);

%createvectortheta

x=r*cos(theta);

%generatex-coordinates

y=r*sin(theta);

%generatey-coordinates

plot(x,y,0,0,'

+'

)%plotthecircle

axis('

equal'

)%setequalscaleonaxes

title(['

Circleofradiusr='

num2str(r)])%putatitle

[x,y]=circlefn(5)

circlefn(3)

摄氏华氏温度转换

functiontemp=tempconvert(Ti,Tf)

C=[Ti:

Tf]'

;

F=9/5*C+32;

temp=[C,F];

喜爱的颜色与宽度:

favourite_color=input('

Whatcolorwouldyoulike?

favourite_width=input('

Inputthewidth='

x=0:

0.1:

y=sin(x)+cos(x);

switchfavourite_color

case'

red'

linewidth'

favourite_width)

green'

g'

yellow'

otherwise

end

21.运算

symsx定义变量

f=sin(5*x)定义函数

df=diff(f)求一阶导数

ddf=diff(f,2)求二阶导数

symsst

f=s^2+t^2

diff(f,t)对t求导

diff(f,s,2)对s求二阶导数

1.f(x)=sin(5x)df/dx=?

2.g(x)=exsin(x)d2g/d2x=?

3.f(s,t)=sin(st)df/dt=?

df/ds=?

4.A=[cos(a*s),sin(a*s);

-sin(a*s),cos(a*s)]

dA/ds=?

%1

symsx

f1=sin(5*x)

diff(f1)

%2

g=exp(x)*cos(x)

diff(x)

diff(g)

diff(g,2)

%3

f2=sin(s*t)

diff(f2,s)

diff(f2,t)

%whyisitjustassameasdiff(f2,s)?

diff(f2)

%4

symsas

A=[cos(a*s),sin(a*s);

diff(A)

Substitution代入

g=x^2*y+5*x+sqrt(y)

subs(g,x,3)x=3时g的值

subs(g,y,3)y-=3时g的值

subs(g,[x,y],[3,3])x=y=3时g的值

Limits极限

limit(f,x,0)x趋近于0的极限

limit(f,x,0,'

left'

)x趋近于0的左极限

right'

)x趋近于0的右极限

symsxh

f=(cos(x+h)-cos(x))/h

limit(f,h,0)

symsa

f=a/abs(a)

limit(f,a,0,'

Quadrature数值积分

quad(F,a,b)

Integration积分

int(f)

int(f,y)

int(f,x,a,b)

symsxn

f1=int(x^n)

pretty(f1)

f2=int(sin(2*x),0,pi/2)

symsapositive

f=exp(-a*x^2)

f3=int(f,x,-inf,inf)

pretty(f3)

preety数学格式书写

f=(x-1)*(x-2)*(x-3)

collect(f)ans=x^3-6*x^2+11*x-6

expand(f)ans=x^3-6*x^2+11*x-6

factor(f)ans=(x-1)*(x-2)*(x-3)

horner(f)ans=x*(x*(x-6)+11)–6

f=cos(x)^2+sin(x)^2simplify(f)ans=1

22.Algebraicequations代数方程solve

Differentialequations微分方程dsolve

ax2+bx+c=0

symsabcx

s=a*x^2+b*x+c;

x=solve(s)

b=solve(s,b)

ax2+bx+c=1

solve('

a*x^2+b*x+c=1'

a*x^2+b*x+c-1'

y2-z2=x2

y+z=a

x2-bx=c

symsxyzabc

eq1=y^2-z^2-x^2;

eq2=y+z-a;

eq3=x^2-b*x-c

[x,y,z]=solve(eq1,eq2,eq3,'

y=2-(x-1)^(2/3)

solve(y)

y=dsolve(‘Dy=1+y^2'

y=dsolve('

Dy=1+y^2'

y(0)=1'

u=dsolve('

D3u=u'

u(0)=1'

Du(0)=-1'

'

D2u(0)=pi'

S=dsolve('

(Dx)^2+x^2=1'

x(0)=0'

[x,y]=dsolve('

Dx+2*x+Dy+y=t'

Dy+5*x+3*y=t^2'

t'

Dx=y'

Dy=-x'

1.y'

=ax

2.f'

=f+sin(t)

3.(dy/ds)2+y2=1

4.y'

=ay,y(0)=b

5.y'

=-a2*y,y(0)=1,y'

(pi/a)=0

6.x'

=y,y'

=-x

7.y'

2+y2=1,y(0)=0

(Node:

Canyousolvethelastone?

F1=dsolve('

Dy=a*x'

F2=dsolve('

Df=f+sin(t)'

F3=dsolve('

(Dy)^2+y^2=1'

F4=dsolve('

Dy=a*y'

y(0)=b'

F5=dsolve(‘D2y=-a^2*y’,‘y(0)=1’,'

Dy(pi/a)=0'

[fx,fy]=dsolve('

Dx=y'

Dy=-x'

y=dsolve('

(D2y)^2+y^2=1'

y(0)=0'

22.三维绘图:

plot(x,sin(x),x,sin(x+pi/3),x,sin(x+2*pi/3))

sin(x)'

sin(x+\pi/3)'

sin(x+2\pi/3)'

boxoff'

boxon'

location'

SouthWest'

NorthOutside'

同一张纸上画图:

subplot(rows,cols,num)row第几行,num第几个图

坐标轴的控制:

plot(x,sin(x))

axis([02*pi–11])

三维图:

x=sin(t)

y=cos(t)

z=t

t=0:

10*pi;

plot3(sin(t),cos(t),t)

gridon;

axissquare

mesh(x,y,z)

surf(x,y,z)

[x,y]=meshgrid(-5:

0.2:

5);

z=cos(x).*cos(y).*exp(-sqrt(x.^2+y.^2)/4);

subplot(1,2,1);

mesh(x,y,z);

mesh'

axissquare

subplot(1,2,2);

surf(x,y,z);

surf'

绘制圆柱面

subplot(2,2,1);

[x,y,z]=cylinder;

surf(x,y,z);

绘制球面,半径为10,球心(1,1,1)

subplot(2,2,3);

[x,y,z]=sphere;

surf(10*x

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 工程科技 > 能源化工

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2