matlab考試文檔(完整版)_第1頁(yè)
matlab考試文檔(完整版)_第2頁(yè)
matlab考試文檔(完整版)_第3頁(yè)
matlab考試文檔(完整版)_第4頁(yè)
matlab考試文檔(完整版)_第5頁(yè)
已閱讀5頁(yè),還剩27頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、符號(hào)運(yùn)算1、 求極限(二元)課本201頁(yè)例7.2 求下列極限。 syms a m x; f=(x(1/m)-a(1/m)/(x-a); %求極限(1) limit(f,x,a) ans = a(1/m)/a/m f=(sin(a+x)-sin(a-x)/x; %求極限(2) limit(f) ans = 2*cos(a) f=x*(x2+1)(1/2)-x); %求極限(3)或者f=x*(sqrt(x2+1)-x); limit(f,x,inf,left) ans = 1/2 f=(sqrt(x)-sqrt(a)+sqrt(x-a)/(sqrt(x2-a2); %求極限(4) limit(f,

2、x,a,left) /應(yīng)該是“right” ans = i/(-2*a)(1/2) 課件:第五章 例5-9 例5-1例5-1 求下列極限。(1) (2)(3) (4)syms h n xl=limit(log(x+h)-log(x)/h,h,0) %單引號(hào)可省略掉l =1/xm=limit(1-x/n)n,n,inf) m=exp(-x) limit(1-cos(x)/(x*sin(x),x,0)ans =1/2syms x;f=(sqrt(x)-sqrt(2)+sqrt(x-2)/sqrt(x*x-4);limit(f,x,2,right)ans =1/2例5-9 k為何值時(shí),下面的方程組有

3、非零解?請(qǐng)寫(xiě)出相應(yīng)的matlab命令x1 -3x3=0 x1+2x2+kx3=0 2x1+kx2 - x3=0syms k a=1 0 -3;1 2 k;2 k -1; d=det(a) d =10-k2-3*k solve(d)ans = -5 2當(dāng)k=-5或k=2時(shí),det(a)=0,從而有非零解!。2、積分,并簡(jiǎn)化。課本204頁(yè) 例7.5 求下列不定積分。 sym x; f=(3-x2)3; %求(1) int(f) ans = -1/7*x7+9/5*x5-9*x3+27*x f=sin(x)2; %求(2) int(f) ans = -1/2*cos(x)*sin(x)+1/2*x

4、syms alpha t; f=exp(alpha*t); %求(3) int(f) ans = 1/alpha*exp(alpha*t) f=5*x*t/(1+x*x); %求(4) int(f,t) ans = 5/2*x*t2/(x2+1) 課件:第五章 例5-4例5-5 求下列積分。(1); (2); (3)syms x f=(x2+1)/(x2-2*x+2)2;g=cos(x)/(sin(x)+cos(x);h=exp(-x2);i=int(f)j=int(g,0,pi/2)k=int(h,0,inf)結(jié)果為: i =1/4*(2*x-6)/(x2-2*x+2)+3/2*atan(x

5、-1) j =1/4*pi k =1/2*pi(1/2)(范圍題)課本第1頁(yè) syms a b x; f=x3*exp(a*x); int(f,x) %第一道 ans = 1/a4*(a3*x3*exp(a*x)-3*a2*x2*exp(a*x)+6*a*x*exp(a*x)-6*exp(a*x) int(f) ans = 1/a4*(a3*x3*exp(a*x)-3*a2*x2*exp(a*x)+6*a*x*exp(a*x)-6*exp(a*x) f=x4*sin(b*x); %第二道 int(f,x) ans = 1/b5*(-b4*x4*cos(b*x)+4*b3*x3*sin(b*x)

6、+12*b2*x2*cos(b*x)-24*cos(b*x)-24*b*x*sin(b*x) int(f) ans = 1/b5*(-b4*x4*cos(b*x)+4*b3*x3*sin(b*x)+12*b2*x2*cos(b*x)-24*cos(b*x)-24*b*x*sin(b*x) 3、求導(dǎo)(兩種類型)課本202頁(yè)(第一種類型diff)例7.3 求下列函數(shù)的導(dǎo)數(shù) syms a b t x y z; f=sqrt(1+exp(x); %求(1) diff(f)ans = 1/2/(1+exp(x)(1/2)*exp(x) f=x*cos(x); %求(2) diff(f,x,2) ans

7、= -2*sin(x)-x*cos(x) diff(f,x,3) ans = -3*cos(x)+x*sin(x) f1=a*cos(t);f2=b*sin(t); %求(3) diff(f2)/diff(f1) ans = -b*cos(t)/a/sin(t) (diff(f1)*diff(f2,2)-diff(f1,2)*diff(f2)/(diff(f1)3 ans = -(a*sin(t)2*b+a*cos(t)2*b)/a3/sin(t)3 f=x*exp(y)/(y2); %求(4) diff(f,x) ans = exp(y)/y2 diff(f,y) ans = x*exp(y

8、)/y2-2*x*exp(y)/y3 f=x2+y2+z2-a2; %求(5) zx=-diff(f,x)/diff(f,z) zx = -x/z zy=-diff(f,y)/diff(f,z) zy = -y/z5.4.2 符號(hào)導(dǎo)數(shù)diff函數(shù)用于對(duì)符號(hào)表達(dá)式求導(dǎo)數(shù)。該函數(shù)的一般調(diào)用格式為:diff(s):沒(méi)有指定變量和導(dǎo)數(shù)階數(shù),則系統(tǒng)按findsym函數(shù)指示的默認(rèn)變量對(duì)符號(hào)表達(dá)式s求一階導(dǎo)數(shù)。diff(s,v):以v為自變量,對(duì)符號(hào)表達(dá)式s求一階導(dǎo)數(shù)。diff(s,n):按findsym函數(shù)指示的默認(rèn)變量對(duì)符號(hào)表達(dá)式s求n階導(dǎo)數(shù),n為正整數(shù)。diff(s,v,n):以v為自變量,對(duì)符號(hào)表達(dá)

9、式s求n階導(dǎo)數(shù)。例5-3求下列函數(shù)的導(dǎo)數(shù)。(1) y=ex(sinx+cosx),求; (2)設(shè)z=e2xcos(3y),求,并求 clear;syms x y y=exp(x)*(sin(x)+cos(x); dy=diff(y,x)dy =exp(x)*(sin(x)+cos(x)+exp(x)*(cos(x)-sin(x) simple(dy)ans =2*exp(x)*cos(x) simplify(dy)ans =2*exp(x)*cos(x)clear syms x yz=exp(2*x)*cos(3*y);f1=diff(diff(z,x),y) f1 =-6*exp(2*x)*

10、sin(3*y)%或f1=diff(diff(z,y),x) 結(jié)果同上!ff2=subs(f1,x,1); ff2=subs(ff2,y,pi)ff2 = -1.6288e-014例5-4 (1) 求y=ln(sinx)的微分(2)求由方程y5+2y-x-3x7=0 所確定的隱函數(shù)的導(dǎo)數(shù)。(3)求函數(shù)z=ln(x2+y2)的全微分, 并化簡(jiǎn)(化簡(jiǎn)過(guò)程中只寫(xiě)最后一個(gè)最簡(jiǎn)結(jié)果)。(4)求擺線,在t=所對(duì)應(yīng)的點(diǎn)的切線斜率 syms x y dx y=log(sin(x); f1=diff(y,x); %(1)求y=ln(sinx)的微分 dy=f1*dxdy =cos(x)/sin(x)*dx sy

11、ms x y; fxy=y5+2*y-x-3*x7; (2)求由方程y5+2y-x-3x7=0 fx=diff(fxy,x);fy=diff(fxy,y); dv=-fx/fy dv = (1+21*x6)/(5*y4+2)syms x y dx dyz=log(x2+y2); %(3)求函數(shù)z=ln(x2+y2)的全微分dz=diff(z,x)*dx+diff(z,y)*dy;dz=simple(dz)dz =2*(x*dx+y*dy)/(x2+y2) syms a t; x=a*(t-sin(t);y=a*(1-cos(t); %(4)求擺線 f1=diff(y,t);f2=diff(x,

12、t); f=f1/f2f =sin(t)/(1-cos(t) ff=inline(f); k=ff(pi)k = 6.1232e-017第二種類型(dsolve)例 7.16 求下列微分方程的解 課本212頁(yè)(執(zhí)行了) y=dsolve(dy-(x2+y2)/x2/2,x) y = x*(-log(x)+2+c1)/(-log(x)+c1) %解(1) y=dsolve(dy*x2+2*x*y-exp(x),x) y = 1/x2*exp(x)+1/x2*c1 %解(2) y=dsolve(dy-x2/(1+y2),y(2)=1,x) y = -1/4*(4*x3-16+4*(20+x6-8*

13、x3)(1/2)(1/3)+1/(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3)+i*(1/4*(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3)+1/(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3)*3(1/2) -1/4*(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3)+1/(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3)+i*(-1/4*(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3)-1/(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3)*3(1/2) 1/2*(4

14、*x3-16+4*(20+x6-8*x3)(1/2)(1/3)-2/(4*x3-16+4*(20+x6-8*x3)(1/2)(1/3) %解(3) x,y=dsolve(dx=4*x-2*y,dy=2*x-y,t) x = -1/3*c1+4/3*c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1/2*2(1

18、/2)*t)-1/4*2(1/2)*c4*exp(-1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)+1/4*2(1/2)*c4*exp(-1/2*2(1/2)*t)*sin(1/2*2(1/2)*t)+1/4*2(1/2)*c4*exp(1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)+1/4*2(1/2)*c4*exp(1/2*2(1/2)*t)*sin(1/2*2(1/2)*t) %解方程組(5)4.泰勒展開(kāi)。課本209頁(yè) 例 7.13 求函數(shù)的泰勒級(jí)數(shù)展開(kāi)式。(執(zhí)行了) x=sym(x); f1=sqrt(1-2*x+x3)-(1-3*x+x2)(1/3);

19、 f2=(1+x+x2)/(1-x+x2); taylor(f1,x,5) %求(1)ans = 1/6*x2+x3+119/72*x4 taylor(f2,6,1) %求(2) ans = 3-2*(x-1)2+2*(x-1)3-2*(x-1)5 數(shù)值部分p48頁(yè)1.解線性方程組(4種方法)x+2y+3z=5x+4y+9z=-2x+8y+27z=6解法一:(逆矩陣) a=1,2,3;1,4,9;1,8,27; b=5,-2,6; x=inv(a)*bx = 23.0000 -14.5000 3.6667解法二:(左除) a=1,2,3;1,4,9;1,8,27; b=5,-2,6; x=ab

20、x = 23.0000 -14.5000 3.6667方法三;(lu分解)p164 a=2,1,-5,1;1,-5,0,7;0,2,1,-1;1,6,-1,-4; b=13,-9,6,0; l,u=lu(a); x=u(lb)x = -66.5556 25.6667 -18.7778 26.5556或者是用 a=2,1,-5,1;1,-5,0,7;0,2,1,-1;1,6,-1,-4; b=13,-9,6,0; l,u,p=lu(a); x=u(lp*b)x = -66.5556 25.6667 -18.7778 26.5556方法四;(qr分解法)p166 a=2,1,-5,1;1,-5,0

21、,7;0,2,1,-1;1,6,-1,-4; b=13,-9,6,0; q,r=qr(a); x=r(qb)x = -66.5556 25.6667 -18.7778 26.5556或者用函數(shù) a=2,1,-5,1;1,-5,0,7;0,2,1,-1;1,6,-1,-4; b=13,-9,6,0; q,r,e=qr(a); x=e*(r(qb)x = -66.5556 25.6667 -18.7778 26.5556p492.求方陣a對(duì)應(yīng)行列式的值的函數(shù)是det(a) a=rand(5)a = 0.9501 0.7621 0.6154 0.4057 0.0579 0.2311 0.4565 0

22、.7919 0.9355 0.3529 0.6068 0.0185 0.9218 0.9169 0.8132 0.4860 0.8214 0.7382 0.4103 0.0099 0.8913 0.4447 0.1763 0.8936 0.1389 b=det(a) b = -0.0071p49求矩陣的秩: a=2,2,-1,1;4,3,-1,2;8,5,-3,4;3,3,-2,2; r=rank(a)r = 4求矩陣的逆: a=1,-1,1;5,-4,3;2,1,1; b=inv(a); a*bans = 1.0000 0.0000 0.0000 -0.0000 1.0000 0.0000

23、-0.0000 0.0000 1.0000 b*aans = 1.0000 0.0000 -0.0000 -0.0000 1.0000 0.0000 0.0000 -0.0000 1.0000 clear a=3,1,1,1;1,3,1,1;1,1,3,1; b=pinv(a)b = 0.3929 -0.1071 -0.1071 -0.1071 0.3929 -0.1071 -0.1071 -0.1071 0.3929 0.0357 0.0357 0.0357 a=0,0,0;0,1,0;0,0,1; pinv(a)ans = 0 0 0 0 1 0 0 0 1求矩陣的跡; a=2,2,3;4

24、,5,-6;7,8,9; trace(a)ans = 16p52求矩陣的特征向量和特征值 a=1,1,0.5;1,1,0.25;0.5,0.25,2; v,d=eig(a)v =特征向量 0.7212 0.4443 0.5315 -0.6863 0.5621 0.4615 -0.0937 -0.6976 0.7103d = 特征值 -0.0166 0 0 0 1.4801 0 0 0 2.5365用特征值的方法解方程: p=3,-7,0,5,2,-18; a=compan(p);a的伴隨矩陣 x1=eig(a)a的特征值x1 = 2.1837 1.0000 + 1.0000i 1.0000 -

25、 1.0000i -0.9252 + 0.7197i -0.9252 - 0.7197i x2=roots(p)多項(xiàng)式p的零點(diǎn)x2 = 2.1837 1.0000 + 1.0000i 1.0000 - 1.0000i -0.9252 + 0.7197i -0.9252 - 0.7197i結(jié)果是一樣的p1753.求非線性方程的解fsolvep176頁(yè) 例6.34myfun.m文件上的代碼function f=myfun(x)x=x(1);y=x(2);z=x(3);f(1)=sin(x)+y+z2*exp(x);f(2)=x+y+z;f(3)=x*y*z;程序代碼 x=fsolve(myfun,

26、1,1,1,optimset(display,off)x = 0.0224 -0.0224 -0.0000 q=myfun(x)q = 1.0e-006 * -0.5931 0.0000 0.0006p2014.(1)求矩陣的最大值,最小值p139 p140 x=-43,72,9,16,23,47; y=max(x)y = 72 y,1=max(x) y=max(x)y = 72 y,l=max(x) %這個(gè)是求向量x中的最大值和該元素的位置y = 72l = 2(2)例6.1 a=13,-56,78;25,63,-235;78,25,563;1,0,-1; max(a,2)%求每行的最大元素

27、ans = 78 63 563 1 min(a,2)%求每行的最小元素ans = -56 -235 25 -1 max(a)%求每列的最大元素ans = 78 63 563 min(a)ans = 1 -56 -235 max(max(a)%求整個(gè)矩陣的最大元素,也可用命令:max(a(:)ans = 563 min(min(a) %求整個(gè)矩陣的最小元素,也可用命令:min(a(:)ans = -2354、函數(shù)的極大值、極小值。四、(1)畫(huà)函數(shù)在-3x3,-2y2的曲面圖(要求:帶等高線,取步長(zhǎng)為0.2),觀察極值點(diǎn)的位置,求極值點(diǎn)和極值(極大和極小)(2*) 畫(huà)函數(shù)在-2x2,-3y3的圖(

28、要求:帶等高線,取步長(zhǎng)為0.1),觀察極值點(diǎn)的位置, 求極值點(diǎn)和極值(極大和極小).(1)命令如下: x=-3:0.2:3; %取步長(zhǎng)為0.2 y=-2:0.2:2; %取步長(zhǎng)為0.2 x,y=meshgrid(x,y); z=(x.2-2.*x).*exp(-x.2-y.2-x.*y); mesh(x,y,z); surfc(x,y,z); % :帶等高線 z1=max(max(z) %求極大值z(mì)1 = 1.4030 x1 y1=find(z=z1); x1=x(x1)x1 = -3 -3 y1=y(y1)y1 = 0 0 z2=min(min(z) %求極大值z(mì)2 = -0.6349 x2

29、 y2=find(z=z2); x2=x(x2)x2 = -3 y2=y(y2)y2 = 1.6000(2)命令如下: clear x=-2:0.1:2; y=-3:0.1:3; x,y=meshgrid(x,y); z=(x.2+6.*x).*exp(-x.2-3.*y.2); mesh(x,y,z); surfc(x,y,z); z1=max(max(z) z1 = 2.8732 x1 y1=find(z=z1); x1=x(x1)x1 = -2 y1=y(y1)y1 = -0.3000 z2=min(min(z)z2 = -2.2728 x2 y2=find(z=z2); x2=x(x2

30、)x2 = -2 y2=y(y2)y2 = -1.7000函數(shù)的最大值,最小值p178頁(yè) 例6.37fxyz.m文件代碼function f=fxyz(u)x=u(1);y=u(2);z=u(3);f=x+y.2./x/4+z.2./y+2./z;程序代碼 u,fmin=fminsearch(fxyz,0.5,0.5,0.5)u = 0.5000 1.0000 1.0000fmin = 4.0000p177頁(yè) 例6.36fx.m文件代碼function f=fx(x)f=x-1/x+5;程序代碼 x,fmin=fminbnd(fx,-10,-1)x = -10fmin = -4.9000 fm

31、inbnd(f,1,10)? undefined function or variable f. x,fmin=fminbnd(fx,1,10)x = 1fmin = 5第六章 多項(xiàng)式,函數(shù)與方程函數(shù)的極大值、極小值。例 6-10 求函數(shù)y=xsin(x2-x-1)在(-2, -1)內(nèi)的極小值 fun=inline(x*sin(x2-x-1),x); x,f=fminbnd(fun,-2,-1)x = -1.2455f = -1.2138 x,f=fminsearch(fun,-1)x = -1.2455f = -1.2138例 6-11求二元函數(shù)f(x,y)= 5-x4-y4+4xy在原點(diǎn)附

32、近的極大值。解:?jiǎn)栴}等價(jià)于求-f(x)的極小值,即max fmin(-f) fun=inline(x(1)4+x(2)4-4*x(1)*x(2)-5); x,g=fminsearch(fun,0,0)x = 1.0000 1.0000g = -7.0000注:在使用fsolve, fminsearch等指令時(shí), 多變量必須合寫(xiě)成一個(gè)向量變量,如用x(1), x(2),。 5.二重積分p160(方法一)fxy.m的內(nèi)容:建立一個(gè)函數(shù)文件fxy.mfunction f=fxy(x,y)global ki;ki=ki+1;f=exp(-x.2/2).*sin(x.2+y);調(diào)用dblquad函數(shù)求解

33、 clear global ki;ki=0; i=dblquad(fxy,-2,2,-1,1)i = 1.5745(方法二)使用inline函數(shù)求解 clear f=inline(exp(-x.2/2).*sin(x.2+y),x,y); i=dblquad(f,-2,2,-1,1)i = 1.5745三重積分(題目在圖片上)clearfun=inline(x.*exp(x.2+y.2),x,y)fun=inlinefunction:fun(x,y)=x.*exp(x.2+y.2)dblquad(fun,0,2,-2,2)ans=881.8304fun=inline(y.*sin(t)+z.*

34、cos(t),t,y,z);triplequad(fun,0,pi,0,1,-1,1)ans=2.0000 畫(huà)圖與應(yīng)用1、 (1)畫(huà)圖plot(p90 例5.5)分段函數(shù) x=linspace(0,10,100); y=; for x0=xif x0=8y=y,1;elseif x0=6;y=y,5-x0/2;elseif x0=4;y=y,2;elseif x0=0y=y,sqrt(x0);endend plot(x,y) 1、(2)極函數(shù)p95 theta=0:0.01:2*pi; rho=sin(2*theta).*cos(2*theta); polar(theta,rho,k);2、微

35、分方程(1)精確p181(ode23)funt.m文件function y=funt(t,y)y=(y2-t-2)/4/(t+1);程序: t0=0; tf=10; y0=2; t,y=ode23(funt,t0,tf,y0); y1=sqrt(t+1)+1; plot(t,y,b.,t,y1,r-);(課堂講授)p181頁(yè)(dsolve與ode23) clear y1=dsolve(dy=(y2-t-2)/(4*(t+1),y(0)=2,t) y1 = 1+(t+1)(1/2) odefun=inline(y2-t-2)/(4*(t+1),t,y); t,y=ode23(odefun,0,1

36、0,2); plot(t,y) y1=sqrt(t+1)+1; plot(t,y,b.,t,y1,r-) n=length(t);e=sqrt(sum(y-y1).2)/n); n,eans = 13.0000 0.0137 t,y=ode45(odefun,0,10,2); y1=sqrt(t+1)+1; n=length(t);e=sqrt(sum(y-y1).2)/n); n,eans = 45.0000 0.0002 t,y=ode113(odefun,0,10,2); y1=sqrt(t+1)+1; n=length(t);e=sqrt(sum(y-y1).2)/n); n,eans

37、 = 17.0000 0.0029(2)近似p212(dsolve)第二種類型(dsolve)例 7.16 求下列微分方程的解 課本212頁(yè)(執(zhí)行了) y=dsolve(dy-(x2+y2)/x2/2,x) y = x*(-log(x)+2+c1)/(-log(x)+c1) %解(1) y=dsolve(dy*x2+2*x*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(1/2)*c4*exp(-1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)+1/4*2(1/2)*c4*exp(1/2*2(1/2)*t)*sin(1/2*2(1/2)*t)-1/4*2(1/2)*c4*exp(1/2*2(1/2)*t)*cos(1/2*2(1/2)*t) y = -1/2*c1*exp(1/2*2(1/2)*t)*sin(1/2*2(1/2)*t)+1/2*c1*exp(-1/2*2(1/2)*t)*sin(1/2*2(1/2)*t)-1/4*2(1/2)*c2*exp(-1

42、/2*2(1/2)*t)*sin(1/2*2(1/2)*t)-1/4*2(1/2)*c2*exp(-1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)-1/4*2(1/2)*c2*exp(1/2*2(1/2)*t)*sin(1/2*2(1/2)*t)+1/4*2(1/2)*c2*exp(1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)+1/2*c3*exp(1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)+1/2*c3*exp(-1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)-1/4*2(1/2)*c4*exp(-1/2*2(1/2)*t

43、)*cos(1/2*2(1/2)*t)+1/4*2(1/2)*c4*exp(-1/2*2(1/2)*t)*sin(1/2*2(1/2)*t)+1/4*2(1/2)*c4*exp(1/2*2(1/2)*t)*cos(1/2*2(1/2)*t)+1/4*2(1/2)*c4*exp(1/2*2(1/2)*t)*sin(1/2*2(1/2)*t) %解方程組(5)第八章 常微分方程 (課件)例8-3 有l(wèi)orenz模型的狀態(tài)方程,試?yán)L制系統(tǒng)相平面圖。解:將變量x,y,z合寫(xiě)成變量向量x,先寫(xiě)m函數(shù)文件lorenzeq.mfunction xdot=lorenzeq(t,x) xdot=-8/3*x(1

44、)+x(2)*x(3);-10*x(2)+10*x(3);-x(1)*x(2)+28*x(2)-x(3);%矩陣中,分號(hào)保證xdot為列向量;再在指令窗口執(zhí)行clear;t,x=ode45(lorenzeq,0 100,0;0;1e-10); subplot(1,2,1);plot(t,x) subplot(1,2,1);plot3(x(:,1),x(:,2),x(:,3);axis(10,50,-20,20,-20,30); 圖8-2作出了解函數(shù)圖和相平面圖3、擬合,兩個(gè)經(jīng)驗(yàn)函數(shù),那個(gè)更好?第150頁(yè)例6.11用一個(gè)三次多項(xiàng)式在區(qū)間在0,2內(nèi)逼近函數(shù)sin。在給出區(qū)間上,均勻地選擇50個(gè)采樣點(diǎn),并計(jì)算采樣點(diǎn)的函數(shù)值,然后利用3次多項(xiàng)式逼近。命令如下: x=linspace(0,2*pi,50); y=sin(x); p=polyfit(x,y,3)p = 0.0912 -0.8596 1.8527 -0.1649以上求得了3次擬合多項(xiàng)式平p(x)的系數(shù),得平p(x)=0.0912x30.8596x2+1.8527x-0.1649。 下面利用繪圖的方法將多項(xiàng)式p(x)和sinx進(jìn)行比較,繼續(xù)執(zhí)行下面命令: x=linspace(0,2*pi,20); y=sin(x); y1=polyval(p,x)y1 = columns 1 t

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論