Programming for Chemical Engineers Using C, C++, and MATLAB

Chapter 2 covered numerical methods that are quite useful in solving chemical engineering problems, which translate into C programs. MATLAB, however, is a mathematical programming language, so it already has numerous existing functions that can perform numerical computation. Some of these functions were developed based on the algorithm we learned when we developed functions in C.
In this chapter, we will further explore MATLAB existing functions including:
The Matrix Method for Linear Equations
The inv() Function
Matrix Left Division (\)
Regression and Curve Fitting
The polyfit() Function
The polyval() Function
Coefficient of Determination and Standard Error of Estimate
Finding Roots
The roots() Function
The fzero() Function
Interpolation
One-dimensional Interpolation
Two-dimensional Interpolation
Numerical Integration
Trapezoidal Integration
Quadrature
Ordinary Differential Equations (ODE)
The ode2 3 () and ode4 5 () Functions
All program listings discussed in this chapter can be found on the CD-ROM.
\Program Listings\Chapter 7\PL7 l.m Program Listing 7.1\Program Listings\Chapter 7\PL7 2.m Program Listing 7.2\Program Listings\Chapter 7\coefdet.m Program Listing 7.3\Program Listings\Chapter 7\stderr.m Program Listing 7.4\Program Listings\Chapter 7\PL7 5.m Program Listing 7.5\Program Listings\Chapter 7\PL7 6.m Program Listing 7.6\Program Listings\Chapter 7\odeapp.m Program Listing 7.7\Program Listings\Chapter 7\PL7 8.m Program Listing 7.8
Let us consider a set of linear equations
where:
x 1, x 2 . x n are unknown varibles
a 11, a 12