University of Tennessee
Department of Chemical Engineering



ChE 505 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. algebraic equations
    • single equation
      • linear
        • no software necessary
      • non-linear
        • rootfinder.m contained in AE505.zip
          includes solutions by
          1. Newton-Raphson method with numerical derivatives
          2. line minimization of Brent method without derivatives
          3. line minimization of Brent method with numerical derivatives
          4. MATLAB "fzero" function

    • systems of equations
      • linear
        • syslineqn_ex.m contained in AE505.zip
          includes
          1. an example problem using MATLAB instrinsic linear algebra routines
        • linalg_v2.m contained in lin_alg.zip
          includes
          1. a short file which examines the system Ax=b for existence and uniqueness of solutions.
          2. Case 1. Reports unique solutions when rank(A) = n.
          3. Case 2. Reports one example of infinite solutions when rank(A) = n-1.
          4. Case 3. Reports there are infinite solutions when rank(A) < n-1.
          5. Case 4. Reports there are no solutions when rank(A) < rank(A|b).
      • non-linear
        • syseqn.m contained in AE505.zip
          includes solutions by
          1. Newton-Raphson method with numerical derivatives
          2. Nelder and Mead's Downhill Simplex method
          3. Powell's Direction Set method
          4. Polak and Ribiere's Conjugate Gradient method (with numerical derivatives)
          5. MATLAB "fsolve" function
        • syseqninput_*.m contained in AE505.zip
          includes example problems:
          1. syseqninput_hx12.m: cross-over in a 1-2 Heat Exchanger
          2. syseqninput_chemeq_NH3.m: chemical eqlbm of an adiabatic N2, H2, NH3 system
          3. syseqninput_VLEpure.m: single component vapor-liquid eqlbm of O2 (van der Waals or Peng-Robinson EOS)
          4. syseqninput_extractor.m: liquid-liquid extractor steady-state material balances
          5. syseqninput_CSTR.m: adiabatic or isothermal CSTR steady-state material and energy balances
        • compare_syseqn.m contained in AE505.zip
          includes
          1. comparison of results of 5 solution techniques of syseqn.m
          2. comparison of computation times of 5 solution techniques of syseqn.m



  2. ordinary differential equations
    • single equation
      • linear
        • syslinode.m contained in ODE505.zip
          includes solutions by
          1. eigenanalysis using MATLAB intrinsic linear algebra routines
      • non-linear
        • sysode.m contained in ODE505.zip
          includes solutions by
          1. Euler Method
          2. Classical Fourth order Runge-Kutta Method

    • systems of equations
      • linear
        • syslinode.m contained in ODE505.zip
          includes solutions by
          1. eigenanalysis using MATLAB intrinsic linear algebra routines
      • non-linear
        • sysode.m contained in ODE505.zip
          includes solutions by
          1. Euler Method
          2. Classical Fourth order Runge-Kutta Method
        • sysodeinput_*.m contained in ODE505.zip
          includes example problems:
          1. sysodeinput_CO2.m: 1-D dynamic vibrational & translational motion of CO2
          2. sysodeinput_CSTR.m: adiabatic or isothermal CSTR transient material and energy balances
        • shooting.m contained in ODE505.zip
          includes solutions to ODE Boundary Value Problems
          1. Shooting Method via the Euler Method
          2. Shooting Method via the Classical Fourth order Runge-Kutta Method



  3. partial differential equations
    • single equation
      • parabolic
        • file.m contained in PDE505.zip
          includes solutions by
          1. method
      • hyperbolic
        • file.m contained in PDE505.zip
          includes solutions by
          1. method
      • elliptic
        • file.m contained in PDE505.zip
          includes solutions by
          1. method

    • systems of equations
      • parabolic
        • file.m contained in PDE505.zip
          includes solutions by
          1. method
      • hyperbolic
        • file.m contained in PDE505.zip
          includes solutions by
          1. method
      • elliptic
        • file.m contained in PDE505.zip
          includes solutions by
          1. method



  4. integral equations
    • single equation
      • one-dimensional integral
        • integrate.m contained in IE505.zip
          includes solutions by
          1. Trapezoidal rule
          2. Simpson's 1/3 rule
          3. MATLAB quad routine
      • multidimensional integral
        • integraten.m contained in IE505.zip
          includes solutions by
          1. multidimensional Simpson's 1/3 rule
          2. Monte Carlo (not posted)

    • systems of equations
      • one or multi- dimensional integral
        • file.m contained in IE505.zip
          includes solutions by
          1. method
        • sysodeinput_*.m contained in IE505.zip
          includes example problems:
          1. syseqninput_VLE_equalarea.m: description
          2. fstatistic.m: description
          3. pvalue.m: description



  5. systems of mixed equations
    • systems of equations
      • linear or non-linear
        • file.m contained in MSE505.zip
          includes solutions by
          1. method
        • sysodeinput_*.m contained in MSE505.zip
          includes example problems:
          1. sysodeinput_prob.m: description





back to ChE 505 Main Page
Contact:  Instructor