필터 지우기
필터 지우기

Terminate program once input is required using system()

조회 수: 3 (최근 30일)
Marc Jakobi
Marc Jakobi 2014년 5월 6일
편집: Marc Jakobi 2015년 2월 27일
Hi. I am trying to run TRNSYS through MATLAB in a script. So far it looks like this (simplified):
Deckname = ['TRNSYS_A1_',num2str(idxAS),'.DCK'];
Deckpath = 'D:\Trnsys_Coll\';
Trnpath = 'C:\Program Files\Trnsys16_1\Exe\';
cd(Trnpath)
Trnrun = ['Trnexe.exe ',Deckpath,Deckname];
system(Trnrun)
cd(Deckpath)
delete(Deckname)
The problem is that the program I am running requires an input (such as enter) to close. So my MATLAB-code gets "stuck" at the line
system(Trnrun)
saying it is busy. Is there a way I can terminate the program once the input is required? It would take too long to do it manually, because it's all in a very long loop.

채택된 답변

Friedrich
Friedrich 2014년 5월 9일
편집: Friedrich 2014년 5월 9일
Hi,
maybe use piping and pipe in a txt file with one empty line. So create a new txt file which contains one line (simply press enter once in the txt file) and save it in some folder with some name. Then when you call your Trnexe.exe pipe in that file by using:
Trnrun = ['Trnexe.exe ',Deckpath,Deckname, '<C:\some_folder\some_file.txt'];
system(Trnrun)
So when the application wants in input it doesn't use STDIN it uses one line of the txt file. This basically simulates the enter press. Let me know if that works for you.
  댓글 수: 1
Marc Jakobi
Marc Jakobi 2015년 2월 27일
편집: Marc Jakobi 2015년 2월 27일
Hi. Sorry for completely forgetting I had posted this... I ended up solving it by
Trnrun = ['!Trnexe.exe ',Deckpath,Deckname,' /h'];
eval(Trnrun);
The /h argument deactivates the input requirement in TRNSYS. But your answer is probably more universal.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MuPAD에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by