Presentation is loading. Please wait.

Presentation is loading. Please wait.

Interpolation and Curve Fitting Prof. Muhammad Saeed Mathematical Modeling and Simulation UsingMATLAB.

Similar presentations


Presentation on theme: "Interpolation and Curve Fitting Prof. Muhammad Saeed Mathematical Modeling and Simulation UsingMATLAB."— Presentation transcript:

1 Interpolation and Curve Fitting Prof. Muhammad Saeed Mathematical Modeling and Simulation UsingMATLAB

2 22 Mathematical Modeling and Simulation Polynomials: p = [1 -2 3 6], y = polyval(p, x)%definition Examples: Poly_01.m, Poly_02.m Poly_01.mPoly_02.m c = conv(a,b) % multiplication Example: Poly_03.m Poly_03.m [q, r]=deconv(a,b)% division Example: Poly_04.mPoly_04.m c = polyder(p)%derivative Example: Poly_05.m Poly_05.m c = polyder(a,b)%derivative of product Example: Poly_06.mPoly_06.m [n,d] = polyder(a,b)%derivative of division Example: Poly_07.mPoly_07.m

3 33 Mathematical Modeling and Simulation intgrl = polyint(p)integral of polynomial p Example: Poly_09.m Poly_09.m intgrl = polyint(p, c)integral of polynomial p Example: Poly_10.m c a constant of integration Poly_10.m r = roots(p)roots of polynomial p Example: Poly_11.m Poly_11.m p = poly(r)polynomial of roots r Example: Poly_12.m Poly_12.m p = poly(x) x must be a square matrix Example: Poly_13.m p is characteristic polynomial ……..Polynomials:

4 44 Mathematical Modeling and Simulation Interpolation I: interp1(x,y,a),Example: InterpFit_01.m InterpFit_01.m interp1(x,y,a,linear), InterpFit_01b.m InterpFit_01b.m interp1(x,y,a,cubic), interp1(x,y,a,spline), Interp1(x,y,a,nearest) interp2(x,y,z,a,b, …….. ), [xx,yy]=meshgrid(x,y), mesh() Example: InterpFit_02.m InterpFit_02.m interp3 interp1q, %it is quicker than interp1 on non-uniformly spaced data because it does no input checking interpft, interpn

5 55 Mathematical Modeling and Simulation Interpolation II: tri=delaunay(x,y), trimesh(tri,x,y,z), tsearch(x,y,tri,[x b],[c d]), dsearch Example: RandomDataInterp_01 RandomDataInterp_01 [pts,area] = convhull(x,y)Example: RandomDataInterp_02 RandomDataInterp_02 voronoi(x,y)Example: RandomDataInterp_03RandomDataInterp_03 griddataExample: RandomDataInterp_04 RandomDataInterp_04

6 66 Mathematical Modeling and Simulation Curve Fitting: p = polyfit(x,y,n) Example: PolyFits_01.m PolyFits_01.m [p, s] = polyfit(x,y,n) [p,s,μ ] = polyfit(x,y,n) yi = spline(x,y,xi) Example: SplineFits_01.m SplineFits_01.m pp=spline(x,y), yi=ppval(pp,xi) hp = pchip(x,y), Example: HermiteSplineFits_01.m HermiteSplineFits_01.m

7 Colormap 77 Mathematical Modeling and Simulation

8 88 Test Matrices: binomial cauchy chebspec chebvand chow circul clement compar condex cycol dorr dramadah fiedler forsythe frankgearmat gcdmat grcar hanowa house invhess invol ipjfact jordbloc kahan kms krylovlauchli lehmer leslie lesp lotkin minij moler neumann orthog parter pei poisson prolate randcolu randcorr randhessrandjorth rando randsvd redheff riemann ris smoke toeppd tridiag triw wathen wilk A=gallery(binomial, n)

9 End 99 Mathematical Modeling and Simulation


Download ppt "Interpolation and Curve Fitting Prof. Muhammad Saeed Mathematical Modeling and Simulation UsingMATLAB."

Similar presentations


Ads by Google