MATLAB EXAMPLES Interpolation and Integration. 58:110 Computer-Aided Engineering Spring 2005. Department of Mechanical and industrial engineering January 2005. Some useful functions. Interpolation.
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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
58:110 Computer-Aided Engineering Spring 2005
Department of Mechanical and industrial engineering
Here is the example to get the polynomial fitting by Lagrange interpolation:
Suppose the original data set is:
To run this example in MATLAB:
3.0000 2.0000 -7.0000 4.0000 -5.0000
That means, the 4th order polynomial is:
Consider the following integration:
The accurate integration is:
To try Simpson’s method, we need write some codes (I_simpson.m):
% Simpson's method of Numerical integration
f = inline('x.*exp(x.^2)');
Run this M-file in command window:
Use the built-in function quad, which uses more accurate adaptive Simpson
quadrature. The default error tolerance is 10e-6.
Compare the results of different methods (all keep 9 digits) in the following table:
To estimate error by step size h:
For Trapezoidal method, it’s O(h2)=O(0.01)
For Simpson’s method, it’s O(h4)=O(0.0001)