Function not recognizing other function variable

Hi there,
I am having a problem with my function Combustaor_solve not recognizing an if statement variable inside another function.
When a run Combustaor_solve, it cannot recognize the variable b in function gibbs, but when a run gibbs from the prompt or inside another code I don’t have this problem.
Combustaor_solve don’t seem to have problems identifying variables in hs_novo, with is a very similar function to gibbs, and I can’t pass this problems to fix Combustaor_solve.
I will post my codes here, as they rather long

Réponses (1)

Voss
Voss le 18 Déc 2021
In gibbs.m, the variable b is only assigned a value if T is at least 200 and not greater than 6000.
if(200 <= T) && (T <1000)
switch n
% assign b in each case
end
elseif (T>=1000)&& (T<=6000)
switch n
% assign b in each case
end
end
In case T is less than 200 or greater than 6000, the variable b is undefined after this if-elseif block. This is the cause of the error.
By the way, since you mention hs_novo.m, it has a similar problem defining a, but you haven't happened to run into it yet.
if T<1000
a = a1;
elseif (T>=1000)&& (T<=6000)
a = a2;
end
% a not defined if T > 6000

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by