MATLAB Files
PlotExpTaylorError.m This program file plots the exponential function and its linear, quadratic and cubic Taylor polynomials on the top graph of a figure. It also plots the associated errors in the bottom graph of the figure. It is mostly an illustration of some of graphing capabilities of MATLAB. Make sure to save this file in a directory where matlab can find it. If you need help, let me know. Once you open MATLAB, click on file, open, and find this file. It will open a separate window in which you can edit this program. To run the program you can either click on the down arrow located in the upper right corner of the second window (this saves and runs the program). Or if you have the file in a place where MATLAB can find it, you can type PlotExpTaylorError.m at the prompt of the original window.
PolyEval.m This is a program file prompts the user for the degree and coefficients of a polynomial. It then prompts the user for a value at which to evaluate the polynomial. It evaluates it the usual way and by calling nested.m that you have written. Make sure PolyEval.m and nested.m are in the same directory. It prints the results of both evaluations to the screen and also prints the difference between the two methods.
Passing a function to a function: These two files demonstrate how you create a Program File which passes a function to a Function File. The program file which creates a function and passes it to a function file is plotslope.m. It defines a function and passes it to the function file findslope.m which approximates the slope given the function, a value of x, and a step size h. The original calling program (plotslope) does some other stuff and then plots a graph of the function, the derivative of the function and the approximate derivative of the function found by findslope. These two files should reside in the same directory. You can run plotslope.m by clicking on the page with the down arrow in the MATLAB editor. You cannot run findslope.m, it is a function file.
The program file for Homework #3 problem 1: SolveThis.m This defines a 4x4 matrix A and a 4x1 vector b. It then calls on three functions that you write: Usol(A,b) Lsol(A,b) and myLUfact(A). It first performs the LU factorization of A (without pivoting), second it solve Uy = b for y, third it solve Lx = y for x. This is the computed solution to Ax = b. It then has MATLAB solve the same system with x = A\b. It computes the difference between your x and MATLAB's x, takes the 2-norm of this difference. It also calculates the 2-norm of each residual. Your residual should be smaller than MATLAB's.
The file for finding the coefficients of an interpolating polynomial using the Vandermonde matrix:Vandemonde.m
The data file for Homework #4: annulusData.m Note: It appears as though there are 7 data points. The first data point is repeated as the last in order to obtain "periodic" data. So there are really only 6 points. You'll notice this if you uncomment the plotting commands and plot the 7 points. One is a repeated so it looks like 6 points ... as it should.
The function file for finding the interval number in which a value of x resides findint.m
The data file for homework #5: FlowDataOne.m