A question on input and output arguments in a function, interesting.
显示 更早的评论
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 个评论
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
2012-9-2
采纳的回答
更多回答(1 个)
Matt Fig
2012-9-2
Even a one-line function is possible in MATLAB. This is a valid function...
function num = myecho(num)
类别
在 帮助中心 和 File Exchange 中查找有关 Distillation Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!