Redirect output from C to Matlab

3 views (last 30 days)
Nikolay Konstantinov
Nikolay Konstantinov on 15 Jan 2018
Commented: Walter Roberson on 15 Jan 2018
I'm using Linux & Matlab R2017.
I have a C program, which have an infinite output via
printf()
which I want to direct to matlab.
I'm able to run this program like this
unix('./prog')
after that I have output, but I dont know how to save it to matlab array.
Actually, I want to make it like FIFO, but no idea how.. As I know in matlab no pipes like in bash.

Answers (1)

Walter Roberson
Walter Roberson on 15 Jan 2018
[status, message] = system('./prog 2>&1');
Now the output will be in message
There is a popen() contribution in the File Exchange, but it is only single direction.
  2 Comments
Walter Roberson
Walter Roberson on 15 Jan 2018
MATLAB is weak on flushing. It exists for the Instrument Control Toolbox, which you are not using. Otherwise you could experiment with using ftell() to determine the current size and then fseek() to that size, but I am not confident that would work with a pipe.

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!