Reading console output

Does anybody have any idea about how to use console output as input in Matlab under linux? My application continuously returns a value and prints it in integer type to system console. I am seeking for ways to input these values to Matlab and plot versus time.

답변 (2개)

Lorenzo Luengo
Lorenzo Luengo 2011년 7월 8일

2 개 추천

I would try using a fifo (in a console)
mkfifo myfifo
and then running my program from matlab using
system('myprogram > myfifo &');
and then read program output just like a normal file:
h = fopen('myfifo','r')
fscanf(format,...)
in this way you can read your program while it's running, and the fifo works like a buffer, when it's empty the fscanf returns empty variables.
I hope this helps.
Rick Rosson
Rick Rosson 2011년 7월 7일

0 개 추천

You can execute your console application from within the MATLAB Environment by calling the system function from either the MATLAB command line or from within a MATLAB script. The system function can execute your application and will return both a status and any results.
For more information:
>> doc system
HTH.
Rick

댓글 수: 1

Yigit
Yigit 2011년 7월 7일
Thank you for the reply but it's not a constant value that console app returns, it's a stream of data and system() fails at this case. Any suggestions?

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

질문:

2011년 7월 7일

Community Treasure Hunt

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

Start Hunting!

Translated by