Errors while trying to setup equation for root finding.

1 visualizzazione (ultimi 30 giorni)
I am trying to set up an equation for root finding to find a, however in the code at the bottom i get an error saying Parse error: Parse error at '=' . usage might be invalid syntax. Does anyone know how to fix this? I'd be grateful for any help.
x_pdo = z_pdo/(1 + a(k_pdo - 1));
x_water = z_water/(1 + a(k_water - 1));
x_glycerol = z_glycerol/(1 + a(k_glycerol - 1));
x_pdo + x_water + x_glycerol - 1 = 0;
  6 Commenti
Torsten
Torsten il 12 Gen 2022
If you have to insert the first three equations into the last to solve for a, also the x_... are unknown.
Otherwise, you could just pick one of the three equations at the top and solve for a.
Tom Goodland
Tom Goodland il 12 Gen 2022
my mistake yeah the x_... are unknown, do you know what function I should use to try to determine a (constant) and x_...? I'm pretty sure fzero would work but I get the error a is an unrecognised function or variable. Do you know any code that would be able to calculate a from the code i've posted as information, if you need anymore information let me know.
Thanks for the help

Accedi per commentare.

Risposte (3)

James Tursa
James Tursa il 12 Gen 2022
Did you mean multiply by the "a"?
x_pdo = z_pdo/(1 + a*(k_pdo - 1));
x_water = z_water/(1 + a*(k_water - 1));
x_glycerol = z_glycerol/(1 + a*(k_glycerol - 1));

Torsten
Torsten il 12 Gen 2022
Modificato: Torsten il 12 Gen 2022
function main
a0 = 1;
a = fzero(@fun,a0)
end
function res = fun(a)
z_pdo = ...;
k_pdo = ...;
z_water = ...;
k_water = ...;
z_glycerol = ...;
k_glycerol = ...;
res = z_pdo/(1 + a*(k_pdo - 1)) + z_water/(1 + a*(k_water - 1)) + z_glycerol/(1 + a*(k_glycerol - 1)) -1.0;
end
  22 Commenti
Tom Goodland
Tom Goodland il 15 Gen 2022
α is the vapour to feed ratio (α = FV / FCwhere FC is the feed flow rate and FV is the vapour flow rate)
Walter Roberson
Walter Roberson il 16 Gen 2022
if a is the same as α then α(kj-1) is 0 when α is 0, and 1+0 is 1, so xj = zj/stuff would be xj=zj/1...

Accedi per commentare.


Walter Roberson
Walter Roberson il 12 Gen 2022
syms a k_pdo x_pdo x_glycerol z_pdo z_glycerol k_glycerol k_water x_water z_water
eqn1 = x_pdo == z_pdo/(1 + a*(k_pdo - 1));
eqn2 = x_water == z_water/(1 + a*(k_water - 1));
eqn3 = x_glycerol == z_glycerol/(1 + a*(k_glycerol - 1));
eqn4 = x_pdo + x_water + x_glycerol - 1 == 0;
eqns = [eqn1; eqn2; eqn3; eqn4]
eqns = 
sol = solve(eqns, [a, x_pdo, x_glycerol x_water])
sol = struct with fields:
a: [3×1 sym] x_pdo: [3×1 sym] x_glycerol: [3×1 sym] x_water: [3×1 sym]
sols = [sol.a, sol.x_pdo, sol.x_glycerol, sol.x_water]
sols = 
sol3 = solve(eqns, [a, x_pdo, x_glycerol x_water], 'maxdegree', 3);
sol3s = [sol3.a, sol3.x_pdo, sol3.x_glycerol, sol3.x_water];
vpa(sol3s)
ans = 

Prodotti


Release

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by