I have a long Matlab script to process data. I want to send him a flag over stdin to say that I have new data to process. I also want to read the flag from stdout when it is processed.
In other words, I have a process A that sends a flag about once per minute to Matlab. I want Matlab to wait until it receives this flag.
Writing to stdout in the matlab process is as simple as calling fprintf. But how can I read from stdin? The documentation fopendoes not mention the input channel as well fread. How to get matlab script to read from stdin?
fprintf
fopen
fread
, , input. myscript.m:
input
str = input('', 's'); fprintf(str); exit;
:
echo Hello world | matlab -nosplash -nodisplay -nodesktop -r "myscript"
, , "Hello world" Matlab.
, , input stdin, fprintf stdout.
- named pipe. mkfifo MY_PIPE, . - MY_PIPE, . , MY_PIPE, . ./program.sh > MY_PIPE. , Matlab, fopen('MY_PIPE', 'r').
mkfifo MY_PIPE
./program.sh > MY_PIPE
fopen('MY_PIPE', 'r')
, :
Linux .
Matlab .
Source: https://habr.com/ru/post/1542079/More articles:Graphhopper на Android-анонимной ошибке pbf файла - androidGrunt: Bower for development and CDN for production - is this possible? - bowerCompilation error in scala - scalaПолучение "использования необъявленного идентификатора", когда я добавляю getter, почему? - iosHow to style default Wordpress player using CSS? - cssWinRT 8.1 Phone - ListView reordering - windows-runtimeIf the condition in @ Html.DisplayFor is asp.net-mvcDynamic object binding behavior is different between WPF and WinRT - c #JQuery: Push FormData? - javascriptAll Articles