How to redirect stdout to stdin in Matlab? Aka how to manage file-descriptors?

我只是一个虾纸丫 提交于 2019-12-06 16:26:23

问题


My peers have created an extremely-hard-to-test novel structure where they use stdout for outputting results. Now I cannot change their code and I need to use their functions. Suppose a function mlfpprint that uses stdout for displaying results -- now I need to check whether its results are correct so I need to get the stdout to a variable for comparison with the correct result. So

How can I manage file-descriptors in Matlab? For example, how can I get stdout to stdin?


回答1:


One idea would be to use diary to save the output of your function call/script to a file. Then parse the file. Also as Oleg recommended, you can use evalc like evalc('functionName').



来源:https://stackoverflow.com/questions/15990891/how-to-redirect-stdout-to-stdin-in-matlab-aka-how-to-manage-file-descriptors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!