Sei sulla pagina 1di 2

ChE 26 Machine Exercise 4 July 12, 2012

Names Answer Key Problem 1: Multiplication Table (15 points) Write a program that will print the following multiplication table, after prompting the user for the number of rows.
1 2 3 4 5 4 6 8 10

9 12 15

16 20

25

Save your work in your group folder, with the filename MEX41.m. Program Code:
clc rows = input('Enter number of rows: '); for i = 1:rows for j = 1:i out = i*j; fprintf('%g\t', out); end fprintf('\n'); end

Problem 2: Unit Conversion (30 points) Write a program that will prompt the user for a maximum Celsius value in the range from -16 to 20. Then, print a table showing degrees F and degrees C until this maximum value is reached. The first value that exceeds the maximum should not be printed. The table should start at 0 degrees F, and increment by 5 degrees F until the maximum (in C) is reached. Both temperature scales should be printed. Use only one decimal place. For example, once executed, the program should look like this:
Enter a maximum temperature from -16 to 20 degrees Celsius: 9 F 0.0 5.0 10.0 15.0 20.0 25.0 30.0 35.0 40.0 45.0 C -17.8 -15.0 -12.2 -9.4 -6.7 -3.9 -1.1 1.7 4.4 7.2

Save your work as MEX42.m. Program Code:


clc maxtemp = input('Enter maximum temp: '); degf = (maxtemp*1.8)+32; fprintf(' F C\n'); for i = 0:5:degf degc = (i-32)*(5/9); fprintf('%4.1f\t%.1f\n', i, degc); end

Problem 3: Mixtures (70 points) Consider the following system below, which is a chemical reactor with multiple streams entering, and a single stream exiting.

The total mass entering the system must equal the total mass exiting the system. This is what we call a steady-state process. For a mixture of A-B, the total mass of A entering the system must equal the total mass of A exiting the system. If A and B are expressed as xA and xB (mass fractions of A and B), then the following equations hold true:

Where i is the stream number. Therefore, for a system with 3 entering streams of an A-B mixture:

Write a program that will loop i times, where i is the number of streams. During each loop, the following quantities must be asked: 1. Mass of stream i 2. Mass fraction of A of stream i At the end of the looping process, the total mass exiting and the mass fraction of A exiting (not mass) must be displayed. Save your work as MEX43.m. Program Code (see next page)

clc stream = input('Enter number of streams: '); masssum = 0; masssumA = 0; for i = 1:stream fprintf('\n\nEnter mass of stream %g: ', i); mass = input(' '); fprintf('Enter mass fraction of A of stream %g: ', i); massfrA = input(' '); masssum = masssum + mass; masssumA = masssumA + (mass*massfrA); end massfrAout = masssumA/masssum; fprintf('\n\nThe TOTAL MASS EXITING is %.4f. \n', masssum); fprintf('The MASS FRACTION OF A THAT IS EXITING is %.4f. \n', massfrAout);

Solve the following problem using your program: For a chemical reactor, with multiple inlet streams and one outlet stream, mixtures of ethanol-water are fed: Stream 1 Stream 2 Stream 3 Stream 4 Stream 5 Mass: 100 kg Mass: 135 kg Mass: 70 kg Mass: 150 kg Mass: 200 kg XEtOH: 0.15 xEtOH: 0.24 xEtOH: 0.50 xEtOH: 0.36 xEtOH: 0.30 1. 2. 3. What is the total mass of ethanol exiting the reactor? 311.9 kg What is the total mass of water exiting the reactor? 618.1 kg What is the mass fraction of A in the exit stream? 0.3354 Stream 6 Mass: 275 kg xEtOH: 0.42

Potrebbero piacerti anche