FUNCTION:
function P = preos_P(V, T, Pc, Tc, w)
R = 8.314;
Tr = T./Tc;
a = 0.4572355289.*(R.^2.*T.^2./Pc);
b = 0.0777960739*(R.*Tc./Pc);
k= 0.37464+1.54226.*w-0.26992.*w.^2;
alpha = (1+k.*(1-Tr.^1/2)).^2;
P = (R.*T./(V-b))-(alpha.*a)/(V.^2+2.*b.*V-b.^2);
end
% takes inputs of temperature (T ), volume (V ), critical pressure (Pc),
% critical temperature (Tc), and acentric factor (w) and returns the pressure.
SCRIPT:
% takes inputs of temperature (T ), volume (V ), critical pressure (Pc),
% critical temperature (Tc), and acentric factor (w)
% and returns the pressure.
clear; clc
T = linspace(273, 373, 100)'; %Temperature in K
Tc = [304.2 190.6 419.6];
Pc = [7.382 4.604 4.02];
w = [0.228 0.011 0,187];
V = .1*1000;
R = 8.314;
P = preos_P (V, T, Pc, Tc, w);
Ps = P;
Ts = T;
plot(Ts,Ps)
legend('carbon dioxide', 'methane', '1-butene', 'Location', 'NorthWest')
title ('[ressures of gases')

 Akzeptierte Antwort

madhan ravi
madhan ravi am 8 Feb. 2019
Bearbeitet: madhan ravi am 8 Feb. 2019

0 Stimmen

  • T has 100 elements whereas Tc has only 3 (reason for the error) , both should have same number of elements
T./Tc % here
  • Matlab interprets that w has 4 elements
w = [0.228 0.011 0,187];
% ^----- has to be a dot
If all the above statements are fulfilled plot can be expected.

Weitere Antworten (0)

Kategorien

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by