how to use a function with multiple inputs for a parameter?
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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)
0 Kommentare
Antworten (1)
Walter Roberson
am 2 Jul. 2021
Change all the / to be ./ for element by element division.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!