Redirect output from C to Matlab
1 view (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
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
Nikolay Konstantinov
on 15 Jan 2018
Edited: Nikolay Konstantinov
on 15 Jan 2018
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.
See Also
Categories
Find more on Low-Level File I/O in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!