Redirecting Command Window output to stdout using mlcaller, error

I am trying to redirect the Command Window output to stdout and stderr when running MATLAB in batch mode. I found this link that answers my question: http://www.mathworks.com/support/solutions/en/data/1-ACT3YN/index.html?product=ML&solution=1-ACT3YN
However, after following the steps, I receive an error: ??? Undefined function or variable 'myFunction'. I don't understand why I am receiving this error, because the function is defined.
Here is my code:
@echo off
echo "running..."
mlcaller "cd 'C:\Documents and Settings\My Documents\folder';myFunction('file.dat','data.txt');"
echo "complete"

 채택된 답변

Walter Roberson
Walter Roberson 2012년 7월 6일

0 개 추천

mcaller will, if I understand correctly, be a .exe that you would invoke, and you would not invoke MATLAB yourself. mcaller will start up MATLAB and run the named command "myFunction" (which is what your .m file would have to be named.)

댓글 수: 5

Oh! I did not know that mlcaller also ran the function, as well as print to standard out. Thanks!
I still don't know why it says it's undefined. "myFunction" is the name of my function.
Is myFunction.m in your current directory?
Experiment with
mcaller "which -all myFunction"
Note: when you finally do get it finding myFunction, you will need to pass the arguments in the mcaller invocation, such as
mcaller "myFunction('file.dat','data.txt')"
When I try mcaller "which -all myFunction" the error goes away, but now standard output says "'myFunction' not found." I am sure that it is in the correct directory.
I now have tried this:
mlcaller "cd 'C:\Documents and Settings\My Documents\folder';myFunction('file.dat','data.txt');"
I do not receive any errors any more, and it runs, but it does not output anything to standard out.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File 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