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

3 ビュー (過去 30 日間)
Rodrigo Luiz
Rodrigo Luiz 2021 年 7 月 1 日
回答済み: Walter Roberson 2021 年 7 月 2 日
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 Center および File ExchangeChemistry についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by