pipe output to stdin of a process and capture output

17 次查看(过去 30 天)
In UNIX, I'd simply run the command like so: cat file_to_stdin | ./minDisj other_input_file > output_file.txt
What I'd like to do is run this in MATLAB, with the text normally contained in file_to_stdin being input directly from MATLAB (e.g. I have a cell array I'd like to print in to the stdin) and then capture and process the output that would come from minDisj's stdout.
The system command seems capable of doing everything but directing chosen MATLAB output to the stdin of the process.
Other that potentially using named pipes (fifos), is there an easier alternative?
I can recompile minDisj above to handle its input in other ways, but I'd prefer not to print out to a file first, as this is both messy and slow, and dealing with fifos seems to be overkill (but may be necessary).

采纳的回答

Walter Roberson
Walter Roberson 2013-3-16
编辑:Walter Roberson 2013-3-16
MATLAB has no facility for interactively piping. You need to write to a named pipe, or write to a file and redirect from the file, or write a mex routine that will handle creating the pipes for you. (Caution: if you do that, watch out for MATLAB liking to handle its own buffering.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by