从 Windows DOS 提示符运行 MATLAB 脚本
我正在尝试从 Windows 命令提示符运行 Matlab 脚本,但有时无法执行它。手动启动时脚本运行良好。 Matlab版本是2011a,Windows是Server 2003 SP2。详细信息:
脚本 mytask.m
位于 E:\Production\Project
内部。这是 Matlab 路径上的SAVED
。
当我将 mytask.m 放入 bin
文件夹中时,它可以通过以下命令正常执行:
`C:\Program Files\MATLAB\R2011a\bin>matlab -r mytask`
如果删除它并尝试在其原始位置访问它,尽管启动了 Matlab 编辑器窗口,但该脚本不会运行:
`C:\Program Files\MATLAB\R2011a\bin>matlab -r "E:\Production\Project\mytask"
请问有什么建议吗?谢谢。
I am trying to run a Matlab script from Windows command prompt but I can't execute it sometimes. The script runs fine when manually launched. Matlab version is 2011a and Windows is Server 2003 SP2. Details:
Script mytask.m
is located inside say E:\Production\Project
. This is SAVED
on Matlab's path.
When I place mytask.m inside bin
folder, it executes fine by the command:
`C:\Program Files\MATLAB\R2011a\bin>matlab -r mytask`
If you delete it and try to access it at its original location, the script doesn't run although Matlab editor window is launched:
`C:\Program Files\MATLAB\R2011a\bin>matlab -r "E:\Production\Project\mytask"
Any suggestions please? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
matlab -r
的 syntax位于换句话说,你需要提供一些可执行的命令作为语句。例如:
但是,matlab似乎没有以这种方式加载自定义路径。如果您有一些自定义路径,则可能必须在
startup.m
中定义它们,并将此startup.m
放在调用 matlab 的目录中。我没有检查自己,但如果您将
E:\Production\Project\
定义为startup.m
中的路径,您可能可以运行matlab -r mytask
没有问题,因为mytask
将被识别为用户函数/脚本。startup.m
的一个简单示例The syntax for
matlab -r
isIn other words, you need to provide some executable commands as the statement. For example:
However, it seems that matlab does not load the customized paths in this way. If you have some customized paths, you probably have to define them in
startup.m
and place thisstartup.m
in the directory where you invoke matlab.I didn't check myself, but if you define
E:\Production\Project\
as the path instartup.m
, you probably can runmatlab -r mytask
without problem, asmytask
will be recognized as a user function/script.A simple example of
startup.m