Question

Write a MATLAB code to read the following data sample of fluid properties. 1.       Read data...

Write a MATLAB code to read the following data sample of fluid properties.

1.       Read data from an input file to run the program. The format of the data file is given below.

Format of input file

# of components (integer)

????,1, ????,1 ,??1, ??1 (critical temperature (K), critical pressure (bar), acentric factor, mole fraction for component 1)

[optional lines for additional component if the number of components is greater than 1, for components 2 up to 5]

T (system temperature, K)

P (system pressure in bar)

Sample file for acetic acid and 1-propanol, equimolar mixture at 385 K and 12.5 bar:

2

594.4 57.86 0.454 0.5

536.7 51.68 0.624 0.5

385

12.5

Check if the molar fraction adds up to 1, if not display error.

Homework Answers

Answer #1

Program:

clc
clear all
n=input('enter number of components')

for i=1:n
disp(i,'component')
Tc=input('critical temperature')
Pc=input('critical pressure')
a=input('accentric factor')
x(i)=input('mole fraction of component(i)')
end

output:

enter number of components 2

component

1.  
critical temperature 594.4
critical pressure 57.86
accentric factor 0.454
mole fraction of component 0.5

component

2.  
critical temperature 536.7
critical pressure 51.68
accentric factor 0.624
mole fraction of component 0.5
system temperature 385
systempresure 12.5

T=input('system temperature')
P=input('systempresure')

output:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions