1 / 13

Numerical Operations

Introduction to Matlab:. Numerical Operations. Numerical Interpolation. S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn. Interpolation Topics. 1D Interpolation Interp1 Command Spline Command 2D Interpolation Interp2 Command. 1-D Interpolation.

yardan
Download Presentation

Numerical Operations

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. Introduction to Matlab: Numerical Operations Numerical Interpolation S. Awad, Ph.D. M. Corless, M.S.E.E. E.C.E. Department University of Michigan-Dearborn

  2. Interpolation Topics • 1D Interpolation • Interp1 Command • Spline Command • 2D Interpolation • Interp2 Command

  3. 1-D Interpolation • The command interp1 is used for One Dimensional Interpolation • Given xdata and ydata • Want to estimate the values of the function: xi=[xi(1) xi(2) … ]’ % values of x

  4. interp1 Command yi=interp1(xdata,ydata,xi,method) • Where the method of interpolation can be: • ‘linear’ for linear interpolation • ‘spline’ for Spline Interpolation • ‘cubic’ for Cubic Interpolation

  5. A Coarse Sine Wave » xdata=[0:pi/4:2*pi]'; » ydata=sin(xdata); » plot(xdata,ydata); » title('Course Sine Wave'); » xlabel('xdata'); » ylabel('ydata');

  6. Interpolated Sine Wave » xi=[0:pi/64:2*pi]'; » yi=interp1(xdata, ydata,xi,'spline'); » plot(xi,yi) » title('Interpolated Sine Wave'); » xlabel('xi'); » ylabel('yi');

  7. Good Fit & Error • Check For Error • Check for Good Fit » plot(xi,sin(xi),'r',xi,yi,'x'); » plot(xi,(yi-sin(xi)));

  8. Spline • Use spline for a cubic spline interpolation method » yi=spline(xdata,ydata,xi); » plot(xi,yi); » title('Cubic Spline Interpolation'); » xlabel('xi'); » ylabel('yi');

  9. 2-D Interpolation • Consider the following sheet of metal with the following temperatures at different points: • We will estimate the temperatures on a finer scale

  10. Plot Original Mesh • Set up Matrices in Matlab » z=[82 81 80 82 84 79 63 61 65 81 84 84 82 85 86]; » xdata =[1:5]; » ydata=[1:3]'; • Plot the Original Mesh » mesh(xdata,ydata,z); » title('Original Metal Temps'); » zlabel('temp');

  11. Original Mesh • Course • Concave

  12. Finer 2-D Interpolation • Estimate Temperature Surface to a finer scale using the interp2 command » xi=[1:0.1:5]; » yi=[1:0.2:3]'; » zi=interp2(xdata,ydata,z,xi,yi,'cubic'); % or ‘linear’ or ‘spline’ » mesh(xi,yi,zi); » title('2D Interp Metal Temps'); » zlabel('temp');

  13. 2-D Interpolated Mesh • Smooth • Concave

More Related