使用 MATLAB“dos”引用可执行文件时出现问题功能
我有一个相当简单的问题困扰着我。我正在尝试使用 MATLAB 作为 shell 来运行从简单 C 程序构建的可执行文件,即使用以下 MATLAB 代码:
FileName = ['D:\Users\person\Desktop\MATLAB\GUI','\Program.exe &'];
dos(FileName);
可执行文件正确开始运行,但崩溃并给出错误:
Debug Assertion Failed! Program: D:\Users\person\Desktop\MATLAB\GUI\Program.exe File: f:\\dd\vctools\crt_bld\self_x86\crt\src\fscanf.c Expression: (stream != NULL)
程序打开一个文本文件,读取输入,执行数学函数,并将输出写回另一个文本文件。我认为此错误意味着从文本文件读取时出现问题,但是,当我单独运行可执行文件(即 Windows 资源管理器双击)时,它会完美执行,正如我所期望的那样。
因此,只是 MATLAB 指向导致崩溃的文件位置。有什么想法吗?谢谢。
I have a fairly simple question that has me stymied. I am trying to run an executable built from a simple C program using MATLAB as a shell, i.e. using the following MATLAB code:
FileName = ['D:\Users\person\Desktop\MATLAB\GUI','\Program.exe &'];
dos(FileName);
The executable correctly begins running, but crashes giving the error:
Debug Assertion Failed! Program: D:\Users\person\Desktop\MATLAB\GUI\Program.exe File: f:\\dd\vctools\crt_bld\self_x86\crt\src\fscanf.c Expression: (stream != NULL)
The programs opens a text file, reads the input, performs math functions, and writes outputs back to another text file. I assume that this error means there is a problem reading from the text file, BUT-- when I run the executable by itself (i.e. Windows Explorer doubleclick), it executes flawlessly, as I would expect.
So, it's only MATLAB pointing to the file location that is causing the crash. Any ideas? Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来相对路径是罪魁祸首。 Matlab 命令从您在 Matlab 中指定的任何目录运行; cmd 从 root 或类似的东西运行(对 Dos 不太了解)。这就是为什么当您指定绝对路径时它会起作用。将您的 Matlab 目录更改为 DOS 根目录,然后查看它是否按原始编码工作。
编辑:请注意,这是 Program.exe 尝试读取的任何文件的路径,而不是 Program.exe 本身的路径。
Sounds like relative paths are the culprit. The Matlab command is running from whatever directory you've specified within Matlab; cmd runs from root or something like that (don't know much about Dos). That's why it works when you specify absolute paths. Change your Matlab directory to DOS root, and see if it works as originally coded.
Edit: Note that it's the path to whatever file Program.exe is trying to read that's the problem, not the path to Program.exe itself.