Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Principles of Matlab (Fall 07) Workout #1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 11

PRINCIPLES OF MATLAB (FALL 07)

WORKOUT #1

1. Use MATLAB to perform the following simple arithmetic statements


1) Evaluate x2 + 2x + 12, where x = 6 (ans: 60)
2) Obtain the value of the universal gas constant, R, in SI units (ans:
0.0821m3.bar/kmol.K)
3) Evaluate log10 s2 / P , where P = 12.56 and s = 0.48 (ans: - 1.1870)
4) Evaluate 3 Val , where Val = 2.5x109 (ans : 1.3572 x 103)
5) Evaluate loge (2q3) / sin (¾π) ; where q = 3.5 (ans : 6.2953)
6) Evaluate loge (s2 - 2s cos (π/5) + 1) ; where s = 0.5 (ans : - 0.8187)
7) If T = 25, P = 18.98 and Q = 2350, evaluate:
5T 2 − 12T + 92
2
(ans : 3.6111 x 104)
3 P 2 sin (π / 4)
+
Q Q 0.333
-1 -1
8) Find sin (0.5) and tan ∞ (ans : 0.5236 and 1.5708)
9) If x = 2 + 3 i ; y = 1.789 - 0.57 i ; Z1 = x - y ; Z2 = x*y and Z3 = x/y.
a) Find the absolute value of x, (ans : 3.6056)
b) Find cos (y), (ans : - 0.2526 + 0.5871 i)
c) Round the real part of Z1 towards zero, (ans : 0)
d) Find the complex conjugate of Z2, (ans : 5.2880 - 4.2270 i)
e) Find the imaginary part of the square root of Z3 (ans : 0.8338)
10) Use MATLAB to find whether or not each of the following is a real number:
−i
i exp(i) ; ii ; -i exp(i) ; -i2 exp(1/i) ; sin2 (i) ; log (i) ; log2(i) ; (i -i)i ; i (i )
8 9 8 8 8 8 9 8 8

2. Use the MATLAB diary command to save the following in a file named session1:
1) Remove all variables from the workspace
2) Format all numbers with a floating point format with 5 digits (scientific notation)
3) Clear the screen, so that the MATLAB prompt appears at the top left of the screen
4) Let a = 112 ; b = -12 ; c = 3π and d = 6 - 12 i (Suppress the appearance of these
variables on the MATLAB command window)
5) Find the value of the variable "Number" if it equals 2a3/ c (ans :9.1527 x 105)
6) Restore the default format for displaying numbers
7) Find the value of the variable "ValueofAngle", if it equals Number/9.1527x105
(ans : 1.0000)
8) Find the arcsine of ValueofAngle, in degrees (ans : 89.8951)
9) Find the inverse cosine of the one sixth (i.e. 1/6) of the real part of the variable "d"
(ans : 0)
10) Get the quotient (division) of the variables "a" and "b" using left division, and put
the result in a variable named "Quotient" (ans : -9.3333)
11) Round the absolute value of Quotient to the nearest integer, and calculate its
exponential, put the result in a variable named "expquot" (ans : 8.1031 x 103)
12) Get a list of the current variables available in the MATLAB workspace
13) Save the current session in a file named firstime.
• Turn the diary command off, exit MATLAB and look for the file named session1,
open it and make sure all steps were recorded
• Enter MATLAB again, load the file firstime and make sure that all the variables
are now in the workspace
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT #2

1. Write a script file called moles.m that calculates the number of moles, n, in kmol,
of 120 liters of hydrogen at 2.5 bars and 50°C. The file should contain one or two
comment lines describing what the script file is calculating. (Remember: PV =
nRT) (Ans: 0.0123 kmol)

2. Write a script file called workt33.m in which the following is performed:


1) Generate an array called arr1 containing values from 0 to π in increments of
π/8. Print arr1 as a column vector named column.
2) Generate an array x starting from 1 to 10 in increments of 1; do not print it.
3) Generate an array y starting from 0.2 to 2, in increments of 0.2; do not print it.
4) Multiply the corresponding elements in x and y and put the result in an array z;
print it.
5) Generate an array called arr2 containing 12 elements numbered from 2 to 90;
do not print it.
6) Divide the summation of the elements of arr2 by the product of the maximum
value in the array x and the mean value of the elements of y, and put the result
in a variable called final and print it. (Ans: 50.1818)

RT αa
3. The SRK equation of state is given as: P = - ;

(V - b)  
V(V + b)
where α, a and b are system dependent parameters: Tc and Pc are the critical temperature
a = 0.42747 R2Tc2/Pc and pressure, respectively
b = 0.08664RTc/Pc
α = [1 + m(1- T / Tc )]2
where m = 0.48508 + 0.55171w - 0.15613w2
(w is the Pitzer acentric factor)
Five kmol N2, at 75°C occupy 10 m3. The critical temperature and pressure of
nitrogen are 126.2 K and 33.5 atm, respectively. The acentric factor is 0.04.
Write a script file called n2press.m that calculates the pressure of nitrogen.
(Ans: 14.3124 bars)
The results of executing the script file should appear as follows, using compact
format:
The data for nitrogen are:
V=
n=
T=
The parameters are:
a=
b=
w=
alpha =
The pressure of nitrogen is:
P=
Note : Leave 5 blank lines before printing the parameters, and five before
the pressure.
4. The following expression approximates the factorial of N ( N!), where N is an
integer greater than or equal zero:
N
⎛N⎞
N! = 2πN ⎜ ⎟ , where e = 2.718282
⎝e⎠
Write a function called fact.m that will calculate N!. Use this function to find the
value of the variable Divresult, if it equals the factorial of 12 divided by 4.7569x108
(Ans: 1)

5. Find the roots of the following equations:


f(x) = x2+8x-48 f(x) = 3x4 - 2x3 + 4x2 - x - 2
(Ans: -12 4) Ans: 0.1849 + 1.2641i
0.1849 - 1.2641i
-0.5077
0.8045

6. The specific heat of CO2 is given by:


Cp(J/mol.K) = 28.29 + 0.411x10-2T + 0.548x10-5T2 - 2.22x10-9T3 (T in °C)
a) Find Cp(25) (Ans: 28.396)
b) If Cp = 28.628 J/mol.K, what is the corresponding temperature? (Ans: ~75°C)
(NOTE: Set format to short e)

7. If n(s) = s3 + 6.4s2 + 11.29s + 6.76 and


d(s) = s4 + 14s3 + 46s2 + 64s + 40
G(s) = d(s)/n(s)
Find the value of the derivative of G(s) at s = 2. (Ans: 1.0000)
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT # 3

1. Use the matrix A, to construct the two matrices B and C, such that B is formed
from the first three rows and first three columns of A, and the matrix C is
composed of the rows 2 to 4 and the columns 2 to 4 of the matrix A.

⎡7 1 1 1⎤
A= ⎢2 11 1 - 1⎥ Get the sizes of all three matrices
⎢1 2 7 2⎥
⎣⎢1 - 1 - 1 8 ⎦⎥

2. Find the product of the B and C, the product of their corresponding elements.

0.1513 -0.0111 -0.0221 -0.0148


3. Find the inverse of A, and the determinant of B. Ans -0.0290 0.0964 -0.0071 0.0175 , 505
-0.0066 -0.0288 0.1424 -0.0384
-0.0234 0.0098 0.0197 0.1242

4. Left/right flip the matrix C and multiply it with -3 3 33


Ans 6 21 6
the matrix D having threes in its diagonal. 24 -3 -3

5. If x = [1 10 12 -13] and y = [-2 6 8 10].


a) Obtain the matrix v (4 x 2), composed of the transpose of x and the
transpose of y
b) Obtain the matrix w (2 x 4), the first row of which is x and the its second
row is y.
c) Obtain the matrix new (6 x 4) composed of A as the first four rows, and w,
as the last two rows.

6. If E is a given non-singular matrix, prove that I = E-1 * E

7. Find the quotient of the matrix composed of the 0.9383 0.0731 0.1607 0.1250
-0.2760 0.9659 0.1250 -0.1250
upper triangle of A and the matrix composed of Ans -0.1364 -0.1656 1.0357 0.2500
the lower triangle of A. -0.1818 0.0649 0.1429 1.0000

8. From what follows find the values of the elements of the array x

⎡4 0 0 0 2 ⎤ ⎡ x1 ⎤ ⎡ 14 ⎤
⎢1 - 3 1 0 0 ⎥ ⎢ x 2⎥ ⎢− 2 ⎥
⎢1 - 1 5 1 - 1 ⎥ ⎢ x 3 ⎥ = ⎢ 13 ⎥
⎢- 3 0 0 4 0 ⎥ ⎢ x 4 ⎥ ⎢ 13 ⎥
⎢⎣0 2 2 0 - 6⎥⎦ ⎢⎣ x 5 ⎥⎦ ⎢⎣− 20⎥⎦
(Ans: x1 = 1, x2 = 2, x3 = 3, x4 = 4 and x5 =5)
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT # 4

1. Plot Y vs. X from the following table:

X 0.25 0.5 0.75 1.00 1.25


Y 4.4941 5.7705 7.4095 9.5140 12.2162

2. Create a vector X containing 30 elements from 0 to 2π. Find the corresponding values of the
vector Y if Y = sin(X). Plot Y vs. X.

3. Using the vector X of problem 2, create a vector Z, such that Z = cos(X ). Plot both, sin(X) and
cos(X) versus X on the same plot. Use a circle symbol (o) for the sine function and a cross symbol
(x) for the cosine. All lines should appear as solid lines.

4. The two variables x and y are related through the expression: y = 7.52x0.75. Generate a vector for x
from 10 to 100 in steps of 5. Find the corresponding y's. Plot y vs. x on a log-log scale. Customize
your plot by labeling the axes and giving a title to the plot. Use gridlines.

5. The concentration of two components, A and B, varies with time according to the following table:

Time, sec 0 10 15 35 40 55 78 101 122


CA, mol/l 0 0.5 1 2.5 3.4 6.2 8.0 9.9 11.5
CB, mol/l 23.0 10 8.5 5.2 3.9 3.2 2.5 2.1 1.59

Create a plot showing the variation of CA and CB with time. Make sure you label all axes properly.

6. The diffusivity, D (cm2/s), of a gas varies with the temperature T(K) according to Arrhenius Law:
D = Do exp (-E/RT); where, Do is the preexponential factor, E is the activation energy for
diffusion and R =1.987 cal/mol.K. Diffusivities of SO2 in fluorosilicone tube are measured at
several temperatures, with the following results:

T(K) 347.0 374.2 396.2 420.7 447.7 471.2


2
D(cm /s) x 1.34 2.50 4.55 8.52 14.07 19.99
106
(so that D=1.34x10-6 cm2/s)

Use a semilogarithmic plot to show the variation of the diffusivity with temperature. (Hint: plot D vs.
1/T on a semi-log scale)

7. Use the subplot command to plot four relations (2x2) on the same graphics window. The top left
plot is that of problem 3, top right is the plot of problem 4, bottom left is the plot of problem 5 and
in the bottom right should appear the plot of problem 6.

8. Use the mesh and/or meshz command to show the effect of the speed and the salt concentration on
the rate of corrosion of zinc, according to the following table. (Label all axes properly)

Speed (rpm) 200 500 1000 1500 2000


NaCl (%)
1 524.35 525.60 566.42 702.84 775.75
2 642.77 672.10 715.21 775.89 820.99
3.5 660.22 689.27 889.57 905.68 1024.98
5 682.06 682.17 869.66 1086.37 1168.06
7.5 640.09 715.74 744.62 860.77 963.76
10 654.15 642.12 583.94 777.49 779.10
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT #5

1. Given each symbolic expression, use MATLAB to create the equilvalent


MATLAB expressions:
d fprime=diff('sqrt(3*x^2+2*x+5)')
i) f = ax2 + bx + c (Ans: a*x^2+b*x+c) ii) f' = 3x2 + 2 x + 5 fprime =
dx 1/2/(3*x^2+2*x+5)^(1/2)*(6*x+2)

3 cos( w )
iii) z = (Ans: 3*cos(w)/sin(2*w/(w+1))
⎛ 2w ⎞
sin ⎜ ⎟
⎝ w +1 ⎠

3 sin( t ) − cos( t2 )⎤ A=
iv) A = ⎡⎢ [3*sin(t),-cos(t^2)]
⎣cos(2 t ) − sin( t ) ⎥⎦ [cos(2*t), -sin(t)]

3s 2 + 2s + 1
v) p = (Ans: (3*s^2+2*s+1)/(4*s-2)) vi) r = e-2t (Ans: exp(-2*t))
4s − 2

2. Find the default independent variable in the following expressions:


i) z = 3ac+4b-2 (Ans: c) ii) f = s3nt (Ans: t) iii) x = 4a+3c+b2+1 (Ans: c)

iv) n = 3r+2s2+5 (Ans: s) v) q = r + 3


3k2 + 2P (Ans: r)
tan(3z) k
vi) y = − (Ans: z)
sin(2 v) p

3. Find the result of adding, subtracting and multiplying the two functions f and f ' of
problem1
(Ans: a*x^2+b*x+c+1/2/(3*x^2+2*x+5)^(1/2)*(6*x+2)
a*x^2+b*x+c-1/2/(3*x^2+2*x+5)^(1/2)*(6*x+2)
1/2*(a*x^2+b*x+c)/(3*x^2+2*x+5)^(1/2)*(6*x+2) )

n
4. Find: i) ∑ (2n − 1)2
1
(Ans: 11/3*n+8/3-4*(n+1)^2+4/3*(n+1)^3)

1
ii) ∑ (2n − 1)2
1
(Ans: 1/8*pi^2)

5. For the following functions f(x) find f (g (x)):


1
i) f = 1− x2 , g = sin2 (x) ii) f = , g = x3 + 2x2 - 3
x3
(Ans: (1-sin(x)^4)^(1/2)) (Ans: 1/(x^3+2*x^2-3)^3)

6. Find the functional inverse of the two functions f(x) given in problem 5
(Ans: i) Warning: finverse(sqrt(1-x^2)) is not unique -(1-x^2)^(1/2)
ii) 1/x^3)

7. Use the determ and the eval functions to find the determinant of the matrix A,
given in problem 1, if t = π/6. (Ans: -0.2687 )
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT # 6

1. Find the first derivatives of the following functions:


sin x
i) f = cxn ii) g = log( x 2 − 1 ) iii) h = iv) phi = g(h(x))
x2 − 1
(Ans: c*x^n*n/x ; 1/(x^2-1)*x ; cos(x)/(x^2-1)^(1/2)-sin(x)/(x^2-1)^(3/2)*x ;
1/2/(sin(x)^2/(x^2-1)-1)*(2*sin(x)/(x^2-1)*cos(x)-2*sin(x)^2/(x^2-1)^2*x) )
(Note: try to simplify the last two answers !!)

2. Find the third derivatives of the following functions:


i) som = sin2x (Ans: -8*sin(x)*cos(x) ) ii) mor = x lnx (Ans: -1/x^2)

3. Perform the following differentiation:


d xn d d
i) u ii) sin− 1 uy iii) sinh− 1 uz
dx dy du
(Ans: u^(x*n)*n*log(u) ; 1/(1-y^2*u^2)^(1/2)*u ; z/(1+u^2*z^2)^(1/2) )

4. Perform the following integrations:


dx dx
i) ∫ sec x dx ii) ∫ cosh
2
u du iii) ∫ iv) ∫ x 2(4x + 12)
x2+ a2
(Ans: log(sec(x)+tan(x)) ; 1/2*cosh(u)*sinh(u)+1/2*u; log(x+(x^2+a^2)^(1/2)) ; -1/12/x-1/36*log(x)+1/36*log(x+3) )
(Note: try to simplify the last two answers !!)

2π ∞ 1 ∞
dx sin x ⎛ ex + 1 ⎞
v) ∫0 1 − 2a cos x + a2 ∫0 x
vi) dx
0
vii) ∫ ln x ln(1 + x )dx
viii) ∫ ln⎜ x
0 ⎝ e −1⎠
⎟dx

(Ans: 2/(-1+a)/(a+1)*signum((a+1)/(-1+a))*pi ; 1/2*2^(1/2)*pi^(1/2) ; 2-1/12*pi^2-2*log(2) ; 1/4*pi^2 )

5. Simplify the following :


4 1
i) cos x + cos 3x (Ans: 7/12*cos(x)+cos(x)^3)
3 4
5 5 1
ii) sin x - sin 3x + sin 5x (Ans: sin(x)-2*sin(x)*cos(x)^2+sin(x)*cos(x)^4)
8 16 16

6. Plot all four functions given in problem 1, in one graphics windows. For the
function f Assume c = 3 and n = 2. Make sure you label all axes, and fully
customize the plots.

7. Plot the two derivatives obtained from problem 2, in one graphics window
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT # 7

1. Use symbolic math to solve the following functions.


i) f(x) = xex + x - 5ex - 5 (Ans : i*pi, 5) ii) f(x) = x4 - ex + 1 (Ans: 0, 1.2611, 8.6135)

2. Use fzero to find the roots of the following functions:


i) f(x) = xx - 2 (Ans: 1.5596) ii) f(x) = x tanx -1 (Ans: -0.8603, 0.8603, 3.4256, 4.7124)

3. If D = Do exp(-E/RT); find the value of E for the following case: (Ans: 2.0000e+003 J/mol)
T = 393 K; D = 7.065 x 10-7 m2/h; Do = 1.303 x 10-6 m2/h; R = 8.314 J/mol.K

4. For the reaction: 2 CO + O2 ═ 2 CO2 , the amount of CO reacting, x, is given by:


x2 ( 6.76 − 0.5x)
= 62.4 * 106
(1 − 0.5x)( 2 − x) 2

Solve for x (Ans: 1.99098 moles)

5. Find the temperatures (in °C) at which the vapor pressure of a substance are 1319.9 and
1821.4 mmHg. The vapor pressure is given by the following formula:
P*(T) = exp[A - B/(T+C)]
Where: T is absolute temperature; A = 15.6782; B = 2154.9; C = -34.42
(Ans: 15.1499°C and 25.1506°C)

6. The specific heat of acetone liquid is given by the formula:


Cp (J/mol.K) = a + bT + cT2 + dT3 (T is in °C)
Where: a = 123; b = 18.6 x 10-2 ; c = -12.78 x 10-5 and d = 34.76 x 10-9 . What is
the temperature at which Cp is 128.9112 J/mol.K? (Ans: 32.5°C)

7. The van der Waals equation of state is :


a 
( P + 2 )( V − b) = RT
V
Find V  (molar volume) for CO2 at T = 300 K and P = 1 atm. Use the ideal gas law to
estimate the starting point for iteration. Use a script file to print the molar volume
estimated using the ideal gas law, and the one using the van der Waals equation of state
and the absolute value of percentage difference between the two values.(DATA : a=3.592,
b = 0.04267 and R = 0.08206)
(Ans: 24.5144 Liters, 0.4226 %)

8. Consider the function


n(s)
H (s) =
d (s)
where: n(s) = s3 + 6.4s2 + 11.29s + 6.76
d(s) = s4 + 14s3 + 46s2 + 64s + 40
For what values of s does H(s) = 0? (Ans: -4.0000 ; -1.2000 ± 0.5000i)
For what values does H(s) blow up? (Ans: -10.0000; -2.0000; -1.0000 ± 1.0000i)
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT # 8

1. Consider
⎡− 5 1 0⎤ ⎡0⎤
⎢ ⎥ ⎢ ⎥
A = ⎢0 - 2 1⎥ , b = ⎢0⎥ , c = [ - 1 1 0]
⎢⎣0 0 1⎥⎦ ⎢⎣1 ⎥⎦
i) Suppose Ax = b, find x.(Ans: x' = [0.1000 0.5000 1.0000]
ii) Suppose yA = c, find y. (Ans: 0.2000 -0.4000 0.4000]

2. Solve the following set of linear equations. (Use a script file to find the solution)
Ax = B
x= 2.5683
⎡7 1 1 1 ⎤ ⎡ x1⎤ ⎡19 ⎤
⎢2 11 1- 1⎥ ⎢ x2⎥ = ⎢- 5 ⎥ -1.3724
⎢1 2 72 ⎥ ⎢ x3⎥ ⎢23 ⎥ 3.6775
⎣⎢1 - 1 -18 ⎦⎥ ⎣⎢ x4⎦⎥ ⎣⎢- 10⎦⎥ -1.2829

3. Solve for xi using LU decomposition:


⎡4 0 0 0 2 ⎤ ⎡ x1 ⎤ ⎡ 14 ⎤ x= 1
⎢1 - 3 1 0 0 ⎥ ⎢ x2 ⎥ ⎢− 2 ⎥ 2
⎢1 - 1 5 1 - 1 ⎥ ⎢ x3⎥ = ⎢ 13 ⎥ 3
⎢- 3 0 0 4 0 ⎥ ⎢ x4 ⎥ ⎢ 13 ⎥ 4
⎢⎣0 2 2 0 - 6⎥⎦ ⎢⎣ x5⎥⎦ ⎢⎣− 20⎥⎦ 5

4.. A mass balance on a system of coupled reactors (5 reactors) gives the following results
6c1 - c3 = 50 Ans:
-3c1 + 3c2 = 0 c=
- c2 - 9c3 = 160 5.2727
- c2 - 8c3 + 11c4 - 2c5 = 0 5.2727
-3c1 - c2 + 4c5 = 0 -18.3636
-11.9174
Find the value of ci’s . 5.2727

5. Solve the following set of algebraic equations:


Ans:
q1 + q2 + q3 = 400 q=
q2 - q5 = -200 62.5000
q1 + q3 - q4 = 310 25.0000
q2 + q3 - q4 - q5 = 10 312.5000
q2 + q3 - q5 = 75 65.0000
262.5000
Use a file named qsol.m to solve the problem.

6. The specific gravity of aqueous nitric acid solutions is given in the following table at 20°C
% 10 15 20 25 30
Sp. Gr. 1.0543 1.0842 1.1150 1.1469 1.1800
Find the specific gravity of an 18% solution and a 32% solution. (Ans: 1.1027, ????)

7. The specific enthalpy (kJ/kg) of superheated steam is shown in the following table as a
function of pressure and temperature
P (bar) 250°C 300°C 350°C
1.0 2975 3074 3176
5.0 2961 3065 3168
10.0 2943 3052 3159

Write one single m-file named enthalpy.m in which you perform the following:
a) Find the specific enthalpy of superheated steam at 250°C and 3.0 bars (Ans: 2968 kJ/kg)
b) Find the specific enthalpy of superheated steam at 320°C and 5.0 bars (Ans: 3106.2 kJ/kg)
c) Find the specific enthalpy of superheated steam at 275°C and 7.0 bars (Ans: 3006.8 kJ/kg)
(Plot the variation of the specific enthalpy with temperature at different pressures)
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT # 9

Solve each of the following problems in a separate script file. Plot the original data
using circles and the fitted relations as continuous lines.

1. Fit a straight line y = ax + b to the tabulated data (Ans: y = 4.8703x -1.8943)

x 1.0 1.5 2.0 3.0


y 2.35 5.53 8.92 12.15

2. You are performing an experiment in which CA, of a reactive species is measured as


a function of time, t, at a fixed temperature. The relationship is:

1/CA = 1/CAo + kt ; k is the reaction rate constant (Ans: 0.0109 min-1)

Use the given data to determine the rate constant k.

t (min) 10 20 30 40 50 60
CA (g/l) 8.1 4.3 3.0 2.2 1.8 1.5

3. Fit a power equation to the following data points, and determine the constants of the relation.

x 2.5 3.5 5 6 7.5 10 12.5 15 17.5 20


y 5 3.4 2 1.6 1.2 0.8 0.6 0.4 0.3 0.3
(Ans: y = ax ; Æ a = 19.5103 , b = -1.4104 )
b

4. Values of the viscosity μ of water (centipoises) have been measured at various temperatures T (°C).
Find the constants which fit an equation of the form:
1
= k1 + k2T + k3T2
μ
T (°C) 10 20 30 40 50 60 70
μ (cp) 1.308 1.005 0.801 0.656 0.549 0.469 0.406
(Ans: k3 = 0.0001; k2 = 0.0205 ; k1 = 0.5481)

5. A heterogeneous reaction is known to occur at a rate described by the following expression:


k1PA
r=
(1 + KAPA + KRPR ) 2
The value of k1 is 0.015 mol/s-g-cat-atm at 400 K. Using the following
rate data at 400 K, estimate the values of KA and KR.
PA (atm) 1 0.9 0.8 0.7 0.6
PR (atm) 0 0.1 0.2 0.3 0.4
r 3.4 x 10-5 3.6 x 10-5 3.7 x 10-5 3.9 x 10-5 4.0 x 10-5

Construct an array, called RESULT, made of three columns: the first one contains r , the second
one contains calculated values for r and the third one contains the difference between r and the
calculated value of r. Print the array. (Ans: KR = 5.0264 ; KA = 19.9392)
RESULT =
1.0e-004 *
0.3400 0.3421 -0.0021
0.3600 0.3569 0.0031
0.3700 0.3722 -0.0022
0.3900 0.3873 0.0027
PRINCIPLES OF MATLAB (FALL 07)
WORKOUT # 10

Solve each of the following problems in a separate script file.

1. Estimate the following integrals using the quad function and symbolically:
0.4 3π / 20

a)
∫0
x exp(− x )dx b)

0
sin(5x + 1)dx

(Ans: 0.0616) (Ans: 0.3035)

2. Suppose the relationship between Cp and T for a given substance is expressed as:
Cp = 0.235 exp(0.0473T1/2)
and you wish to evaluate:
150

 (cal / g) =
ΔH

1800
CpdT

Estimate ΔH for 500 g of this substance. (Ans: -865.5592 kcal/g)

3. The specific heat of carbon monoxide can be obtained by the following formula:
Cp (J/mol.K) = 28.95 + 0.4110x10-2T + 0.3548x10-5T2 - 2.22x10-9T3 (T in °C)
The mean heat capacity of carbon monoxide as it goes from 25°C to 1500°C can be
defined as :
1500
∫ Cp dT
Cp (25 → 1500) = 25 (Ans: 32.8851 J/mol.K)
1500 - 25
1.0e+003 *
a) Calculate the mean heat capacity C p for carbon monoxide. 0.1000
0.2000
0.0292
0.0295
b) Generate an array of two columns and 10 rows, in which 0.3000
0.4000
0.0297
0.0300
the first column is the temperature, from 100°C to 1000°C, 0.5000
0.6000
0.0303
0.0306
and the second column is the corresponding mean heat 0.7000
0.8000
0.0308
0.0311
capacities. 0.9000
1.0000
0.0314
0.0317

4. The behavior of a batch reactor for a second order irreversible reaction can be
described by the relation:
x


1 1 + εx
kt = dx
Co (1 − x) 2
0
where: x is the fractional conversion
k is the reaction rate constant
Co is the initial concentration of reacting component
ε is the fractional change in volume of the reactor between zero
conversion and complete conversion
t is the time of the reaction

For k=6.2 x 10-4, Co = 10 and ε = 0.2, find the time necessary to reach a fractional
conversion, x, of 0.4. (Ans: 112.5558 )

You might also like