
234 Programming for Chemical Engineers
Line 5: This computes for S
r
.
Line 6: The degrees of freedom df is computed in this line.
Line 7: Finally, this line computes for the coefficient of determination and then
assigns the value to
result.
FINDING ROOTS
The roots() Function
For values of polynomials equated to zero, finding the root using MATLAB is
quite easy. The available function is
roots(), which has a format roots(coef)
where coef is a vector containing the coefficients of the polynomial presented in
descending powers of x.
Let us apply the function with this example problem.
Example Problem 7.2. A cylinder tank is to be filled