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

조회 수: 14 (최근 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 CenterFile Exchange에서 Chemistry에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by