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

답변 (1개)

Voss
Voss 2021년 12월 18일
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

카테고리

도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

질문:

2021년 9월 8일

답변:

2021년 12월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by