University of Tennessee Department of Chemical Engineering

ChE 240 Library of MATLAB® Subroutines

I am a strong believer in learning by example, especially in programming. If you have an elementary program that shows the syntax for doing a job A and another elementary program that shows the syntax for doing a job B, then you have everything you need to know to write a program to do both A and B.

That is the philosophy behind providing these codes, rather than making you write them from scratch. I have written some basic subroutines (MATLAB® *.m files) and I expect you to use this library of subroutines to accomplish tasks more complicated than those explicitly done in the subroutines themselves.

Given the rapid rate at which new programs, software, and hardware are being developed, it is often the case that no manual or instruction exists. What one has to rely on is a few paltry examples posted on the web by other hardy souls braving the perils of novel and untested systems.

So, this course encourages you to use the examples available and requires you to be able to read, understand, and modify the code to suit your own purpose.

 (These codes have been zipped with WinZip®. You must unzip them and move them to your current working MATLAB® directory in order to use them.) 1-1 Shell and Tube Heat Exchanger Solver Includes Iteratively solve for unknown shell and tube outlet temperatures Has a physical property table for water built in Doesn't work for cross-over (all hot fluid temps must be greater than all cold fluid temps) Ordinary Differential Equation Solver Includes single first order ODE IVP using Euler and Runge-Kutta routines (sysode.m) n-equation system of first-order ODE IVP's using Euler and Runge-Kutta routines (sysode.m) shooting method (using Euler or RK4) for nth-order ODE BVP's (shooting.m) Regression Routines (regress.m) Includes simple regression (single-variable linear regression) n-variable linear regression nth-order single-variable polynomial regression (e.g. cubic spline) Integration Routines (integrate.m) Includes Numerical Integration of a function using the Trapezoidal Rule Numerical Integration of a function using Simpson's 1/3 Rule Numerical Integration of a function using Gaussian Quadrature Numerical Integration of data using the Trapezoidal Rule or Simpson's 1/3 Rule Systems of Nonlinear Algebraic Equations Solver Includes 1 non-linear algebraic equations solver (rootfinder.m) n-equation system of non-linear algebraic equations solver (syseqn.m) An example of solving a system of nonlinear equations:  the material balance on an extractor with 2 components in the feed, solvent, extract, and raffinate streams.

back to ChE 240 Main Page
Contact:  Instructor