1 / 7

Matlab Integral

Matlab Integral. TRAPZ(x,y) QUAD(FH,A,B) DBLQUAD(FH,X MIN ,X MAX ,Y MIN ,Y MAX ) TRIPLEQUAD(FH,X MIN ,X MAX ,Y MIN ,Y MAX ,Z MIN ,Z MAX ). Creating a function handle, FH, from a function, f: 1- inline object: FH=inline(‘f’)

lucia
Download Presentation

Matlab Integral

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Matlab Integral TRAPZ(x,y) QUAD(FH,A,B) DBLQUAD(FH,XMIN,XMAX,YMIN,YMAX) TRIPLEQUAD(FH,XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX) Creating a function handle, FH, from a function, f: 1- inline object: FH=inline(‘f’) 2- function handle: Write a m_file with the name ‘filename.m’ in the following format: function z=filename(x,y) z=f(x,y) FH=@filename

  2. Trapz computes the integral of Y with respect to X using the trapezoidal method Cumtrapz computes the cumulative integral of Y with respect to X using trapezoidal integration. Trapz(x,y); cumtrapz(x,y) x=linspace(-1,2,100); y=humps(x); format long Area=trapz(x,y) plot(x,y) grid on xlabel(‘x’) ylabel(‘humps(x)’) title(‘integral of humps’) z=cumtrapz(x,y) hold on plot(x,z) hold off Area =26.34473119524596

  3. QUAD(FH,A,B) y=inline('1./(x.^3-2*x-5)') Q = quad(y,0,2) test2a.m file: function y=test2a(x) y=1./(x.^3-2*x-5); Answer: y = Inline function: y(x) = 1./(x.^3-2*x-5) Q = -0.4605 quad(@test2a,0,2) ans = -0.4605

  4. DBLQUAD(FH,XMIN,XMAX,YMIN,YMAX) Evaluates the double integral of f(X,Y) over the rectangle XMIN <= X <= XMAX, YMIN <= Y <= YMAX. f can be an inline object or a function handle. Q = dblquad(inline('y*sin(x)+x*cos(y)'), pi, 2*pi, 0, pi) or Q = dblquad(@integrnd, pi, 2*pi, 0, pi) where integrnd.m is an M-file: function z = integrnd(x, y) z = y*sin(x)+x*cos(y); Answer: Q = -9.86960437725457

  5. TRIPLEQUAD(FH,XMIN,XMAX,YMIN,YMAX,ZMIN,ZMAX) evaluates the triple integral of FUN(X,Y,Z) over the three dimensional rectangular region XMIN <= X <= XMAX, YMIN <= Y <= YMAX, ZMIN <= Z <= ZMAX. Q = triplequad(inline('y*sin(x)+z*cos(x)'), 0, pi, 0, 1, -1, 1) Answer: Q = 1.99999999436264

  6. Line Integral Surface Integral Volume Integral

  7. Line Integral See Solution Q = quad(inline('-18.*sin(phi).*cos(phi)'),(pi/2),pi) Q = 8.99999998379294

More Related