External program is not creating output

3 次查看(过去 30 天)
Hello,
I am using Matlab R2013a and I want to run an external interactive program as non-interactive from within a matlab-script by piping the Input either through echoing a string or through a text-file. The Input consists of a string and 2 numbers. If I call
echo -e " 'String' \n 1 \n 2.2" | myFotran
in the unix shell, it creates an Output file as expected. Doing the same in matlab with
unix('echo -e " ''String'' \n 1 \n 2.2" | myFotran')
is not generating the Output-file. Why? Can someone help me? I can't change the external program, since it is not mine.
  29 个评论
Jan
Jan 2017-6-7
If you found a solution finally, the discussion was necessary and successful. It is the nature of questions, that a solution is sometimes not efficient.
Please post your solution as an answer and accept it. Thanks.
Walter Roberson
Walter Roberson 2017-6-8
The shell echo does not use the fortran unit numbers, so I would not have expected the behavior to change for an echo test.

请先登录,再进行评论。

采纳的回答

Matthias Otten
Matthias Otten 2017-6-8
编辑:Matthias Otten 2017-6-8
the following did it for me. Setting STDOUT was not necessary
setenv('GFORTRAN_STDIN_UNIT', '5')
setenv('GFORTRAN_STDOUT_UNIT', '6')
setenv('GFORTRAN_STDERR_UNIT', '0')
!myfortran < Input.txt
setenv('GFORTRAN_STDIN_UNIT', '-1')
setenv('GFORTRAN_STDOUT_UNIT', '-1')
setenv('GFORTRAN_STDERR_UNIT', '-1')
The following threads contain the needed Information. Thank you Walter Roberson and Jan Simon. https://fr.mathworks.com/matlabcentral/answers/44388-or-system-or-unix-input-redirection https://fr.mathworks.com/matlabcentral/answers/91919-why-does-the-output-of-my-fortran-script-not-show-up-in-the-matlab-command-window-when-i-execute-it

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by