微積分 第三次上機 matlab 教學

37
1 微微微 微微微微微 Matlab 微微 2007/12/04 朱朱朱

Upload: signa

Post on 29-Jan-2016

83 views

Category:

Documents


1 download

DESCRIPTION

微積分 第三次上機 Matlab 教學. 2007/12/04 朱育正. Outline. Matlab 之基本操作 向量與矩陣運算 2D 繪圖 微分運算 實作. Matlab 之基本操作. Matlab 之基本操作. Clear : 去除所有定義過的變數名稱。. Matlab 之簡易數學. Matlab 變數的名稱大小寫有分。所以 x 和 X 將會不同 有些 Matlab 內定的變數盡量不拿來當變數. Matlab 之 簡易數學. 基本運算 : 加( Addition ) : + 減( Sudtraction ) : - - PowerPoint PPT Presentation

TRANSCRIPT

  • Matlab 2007/12/04

  • OutlineMatlab2D

  • Matlab

  • MatlabClear

  • MatlabMatlab x X Matlab

  • MatlabAddition:+Sudtraction:-Multiplication:*Division: / or \ (21.9/3 or 3\21.9)Exponentiation: ^ 34=3^4abs abs-1sqrt

  • sin(t)asin(t)exp(t)log(t)10log10(t)

  • a * b a .* b

  • 2D--plotplot (,)

  • 2Dxlabel(name ) xylabel(name) ytitle(name)

  • -

  • ->>x=0:2:8x= 0 2 4 6 8>>y=sqrt(x)y= 0 1.4142 2.0000 2.4495 2.8284

  • ->>gradient(y,x)ans = 0.7071 0.5000 0.2588 0.2071 0.1895 yx=0,0.7071yx=2,0.5000yx=4,0.2588yx=6,0.2071yx=8,0.1895

  • ->>x=linspace(0,2*pi,36);>>y=sin(x);>>dy=gradient(y,2*pi,36);>>plot(x,y,x,dy);legend('sin(x)','d sin(x)/dx')>> Interp1(x,dy,2,'spline')>>cos(2)

  • -

  • -

  • -plot(x,y,x,dy,x,cos(x));legend('sin(x)','d sin(x)/dx','cos(x)')

  • -

  • ->>diff([3 5 9 4 1])ans = 2 4 -5 -3>>x=0:0.2:6;>>y=x.*sin(x); >>dy=diff(y)./diff(x);>>plot(x,y,x(1:end-1),dy);legend('y(x)','dy/dx')

  • ->>plot(x,dyt,x(1:end-1),dy);legend('exact','approx')

    >>dy2 = gradient(y,0.2);>>plot(x,dyt,x,dy);legend('exact','approx')

  • -

  • -

  • -

  • -

  • gradient

  • Midtermlimit functionAA+:A96325122_lab3BB+:B96325122_lab3

  • ReferenceMATLAB7