System and System.Diagnostics.Process
19 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Walter Mabry
am 5 Aug. 2020
Beantwortet: Rahul J Hirur
am 3 Jun. 2022
I have a program that runs in the console window on windows 10. The program puts out a continuos stream of data and i need to take the data and save it as a numeric matrix in MatLab. I could easily do this with the system() function however, I need to use the data in real time as the program in the console is still running and feeding me new data. So if you just simply use the system() funtion then matlab will never move past that line becasue the program never stops running in the command window. I have read about System.Diagnostics.Process() but I am not sure how to use it and matlab does not have documentation on what the methods actually do. Any help would be greatly apreciated.
0 Kommentare
Akzeptierte Antwort
Mario Malic
am 26 Aug. 2020
Bearbeitet: Mario Malic
am 26 Aug. 2020
See my answer here as well https://www.mathworks.com/matlabcentral/answers/583955-get-the-status-using-system-command-when-program-has-been-closed#answer_485480
Here's an example with simple app.
Process = System.Diagnostics.Process;
Process.Start('notepad.exe');
% You can check if process is still running
while(Process.HasExited == false)
% do something
end
If you are running an executable file with input arguments, see the answer here: https://www.mathworks.com/matlabcentral/answers/264364-executable-in-matlab-help#answer_206712
Alternative below
I am onto this question as well, you can run
system('file.exe %')
With ampersand, MATLAB won't wait for the exit of program.
while (% stop the key with press of a button or however you want to)
% your code
end
0 Kommentare
Weitere Antworten (1)
Rahul J Hirur
am 3 Jun. 2022
Hello Walter,
@Walter Mabry , Were you able to print ouptput in the console/windows command prompt ?
If you were sucessful, Can you share the snippet of teh script ?
0 Kommentare
Siehe auch
Kategorien
Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!