A question on input and output arguments in a function, interesting.
Show older comments
Hello fellows users of MATLAB. Let me state my question, I really appreciate your attention. I am programming the code of a program which represents a distillation column with controllers. As part of the global iterative process I need to stablish some functions which calculate Entalphies, Liquid Flowrates, Temperatures and Vapor compositions. My problem is that I have a function that needs as input argument a Temperature value(TBUBLE) and the expresion in the function also calculates a temperature value because the program needs it, this is an output value (TBUBLE). In your experience: Is it possible to declare a function with a name for an input argument exactly the same as the name for an output argument?, as in my case TBUBLE.
Thank you .
function [TBUBLE,YBUBLE]=BUBPT(XS,PEP,AVPP,BVPP,TBUBLE)
*
XSS=XS(1:5);
%PEPP=PEP
AVPPP=AVPP(1:5);
BVPPP=BVPP(1:5);
% LAZO=0.0;
% Initial values
SUMYTA=0.0;
FSLOPEE=0.0;
while LAZO <=50
for K=1:5
%TBUBLE IS NEEDED AS INPUT ARGUMENT
PSS(K)=exp(BVPPP(K)+AVPPP(K)/(TBUBLE+460.));
YBUBLE(K)=PSS(K)*XSS(K)/PEP;
SUMYTA=SUMYTA+YBUBLE(K);
end
if abs((SUMYTA-1.)<=0.00001)
% disp('TEMP-LAZO')
break
else
FEE=SUMYTA*PEP-PEP;
TSQQ=(TBUBLE+460.)^2;
end
for K=1:5
FSLOPEE=FSLOPEE-AVPPP(K)*XSS(K)*PSS(K)/TSQQ;
end
%TBUBLE is calculated again
TBUBLE=TBUBLE-FEE/FSLOPEE;
% Increase counting
LAZO=LAZO+1;
disp('TEMP-LAZO')
end
end
2 Comments
abs((SUMYTA-1.) <= 0.00001) does most likely not, what you are expecting: the ABS() is applied after the <= comparison. But the operation abs(true) or abs(false) is not really useful. Do you mean:
abs(SUMYTA-1.) <= 0.00001
Pepe Vázquez
on 2 Sep 2012
Accepted Answer
More Answers (1)
Matt Fig
on 2 Sep 2012
Even a one-line function is possible in MATLAB. This is a valid function...
function num = myecho(num)
1 Comment
Pepe Vázquez
on 2 Sep 2012
Categories
Find more on Distillation Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!