WHILE Loop using called functions from shared library

I am using Matlab with a library called epanet. I am trying to retrieve water quality data from the simulation when tleft=79200. I do not think the loop is set up correctly. If anyone sees any issues with how I have the loop set up, or any suggestions as to how to do it differently, please let me know.
%Run water quality and extract water age data for nodes of interest.
t = 0;
tleft = 1;
age = 0;
index = 9693;
calllib('epanet2','ENopenQ');
calllib('epanet2','ENinitQ',1);
while tleft >0
[error1, t] = calllib('epanet2','ENrunQ',t);
[error2, tleft] = calllib('epanet2','ENstepQ', tleft);
if tleft <= 79200
[errcode, age]=calllib('epanet2','ENgetnodevalue',index, 12, age);
end
end

댓글 수: 4

Is it certain that as you use ENstepQ that you will eventually get to either 79200 or 0?
Is there a reason for getting the node value for any node other than 79200? Is that there in case you reach 0 before 79200 and want to see the "last" value you reached?
Is it valid to get the node value when you have reached 0?
Is this loop working?
I'm trying to execute multipe times "Calllib" the same function but it doenst work for me.
@Peer, this is a 4 year old question, it's unlikely that the OP is still around to tell you if his loop is working or not. In any case, if your problem is generically with calllib and not just calllib when used with this epanet library, then it's a completely unrelared question, so start a new question.
Note that it doesn't work for me is a useless statement if it's not accompanied by
  • the code that doesn't work
  • a description of what doesn't work actually mean. If you get an error, then we need the full text of the error messge. If you get a different result than what you expected then we need a description of what you expected and what you got instead.
Hey Guillaume,
yes i have a question to another code and problem. Maybe you can take a look?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Import and Export에 대해 자세히 알아보기

질문:

CJ
2016년 4월 11일

댓글:

2020년 2월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by