how to use a function with multiple inputs for a parameter?

16 次查看(过去 30 天)
Hi everyone, I'm trying to use this mathematica script (from Smith, J. M. (1950). Introduction to chemical engineering thermodynamics.) in Matlab. It isn't a complex script, but a I want to vary the temperature parameter (t) and obtain the fugacities coefficients for each temperature. How can I do this?
That's the function that I'm using in matlab:
function phi = phib(t, p, tc, pc, omega)
pr = p/pc;
tr = t/tc;
b0 = 0.083 - 0.422/tr.^1.6;
b1 = 0.139 - 0.172/tr.^4.2;
phi = exp( (b1*omega + b0)*pr/tr );
end
So, I use the file exeBolT.m to calculate the fugacity (phi)
clear all; close all; clc
t = [323.15; 400];
p = 0.25;
tc = 535.5;
pc = 41.5;
omega = 0.323;
phi = phib(t, p, tc, pc, omega)
Then, when I execute the file, I obtain
Error using /
Matrix dimensions must agree.
Error in phib (line 8)
phi = exp( (b1*omega + b0)*pr/tr );
Error in exeBolT (line 9)
phi = phib(t, p, tc, pc, omega)

回答(1 个)

Walter Roberson
Walter Roberson 2021-7-2
Change all the / to be ./ for element by element division.

类别

Help CenterFile Exchange 中查找有关 Chemistry 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by