Please write a Matlab code to solve this problem and show your Matlab script that is typed in the window. Thanks
OBJECTIVES Understand the difference between interpolation and curve fitting. Use polyfit for basic polynomial interpolation. Learn how to control end conditions with the spline function. Learn how to use the interpl function. Understand how spline interpolation is useful to reduce oscillations between data points. Learn how to formulate (by hand) Lagrange interpolating polynomials. INSTRUCTIONS: Write a single MATLAB m-file that solves all problems below. Call external user-defined functions from your m-file where instructed as well as to minimize naming conflicts, organize your work and simplify debugging. For each problem, write the requested answers to ASCII data files with the exact filenames specified (e.g. "A3.dat"). Submit your main m-file and all associated function m-files to your instructor; submit the ASCII data files to the instructor by email. NOTE: You should be able to complete this entire assignment in a single mfile with no for loops or logic. Problem 1 Bessel functions arise in a variety of engineering and science applications. These functions are not amenable to straightforward evaluation so they are usually compiled in standard tables, for example: 1.8 2.0 2.2 2.4 J()0581505767 0.5560 0.5202 2.6 0.4708 Use this data to estimate the 1st order Bessel function corresponding to x - 2.13, namely J(2.13) using: ) A 4h order interpolating polynomial generated using MATLAB polyfit. Calculate the relative error (e) in this estimate. For the error calculation, determine the true value using the built-in function besselj. See MATLAB help for syntax and more information about Bessel functions. The subscript 1 in Ji(x) indicates the order of the Bessel function (the nu input you see in the help documentation). A cubic spline with "not-a-knot" end conditions generated using MATLAB. Calculate the relative error (a) in this estimate as well For the next two interpolations, formulate the interpolating polynomial by hand and simply write it into your m-file as an equation, or multiple equations if you want to break up the long equation for part (d). t order Lagrange interpolating polynomial. Calculate the relative error (a) in this estimate. A 2nd order Lagrange interpolating polynomial. Make sure to use the closest three data points. Calculate the relative error (a) in this estimate. ANSWERS: For each part, save your estimate and e to a 2-element row vector and write to Aldat thru A4.dat for parts (a) through (d) respectively