命令提示符在运行软件以及生成报告和输出文件的所有方面都运行良好。要生成包含所需结果的输出文件,我们必须运行使用参数文件的报告程序的可执行文件。例如,如果我要在命令提示符下实现这些步骤,它会是这样的:
“path\report.exe” –f Report.rwd –o Report.rwo
输出文件是 Report.rwo,该文件将包含导出的变量。
现在要在 Matlab 中实现这一点,下面是一个小脚本,给出了我想要实现的要点。它为每次运行调用软件并提取数据。
for nr=1:NREAL
dlmwrite(‘file.INC’,file(:,nr),’delimiter’,’\n’); % Writes the data file for each run
system('"path\file.dat"'); % calls software
system('"path\Report.rwd" –o "path\Report.rwo"'); % calls report
[a,b]=textread(‘"path\Report.rwo".rwo’,’%f\t%f’); % Reads the data and store it in the variable b
end
所以我有两个问题:
1) 当我在 Matlab 中运行此脚本时,它不会生成输出文件 Report.rwo。因此,由于缺少文件,它在到达包含“textread”函数的行时会出错。
2) 每次 Matlab 调用报告(.rwd 文件)时,它都会提示我按 Enter 或键入 'q' 退出。如果假设有数百个文件要运行,那么对于每个文件,我都会被提示按 Enter 继续。以下行导致提示:
system('"path\Report.rwd" –o "path\Report.rwo"'); % Calls report
旧编辑:我的问题有 2 个更新,如下所示:
更新 1: Jacob 似乎解决了我上面的问题的第 2 部分。它运行良好。但是,只有当我能够运行涉及运行数百个文件的整个程序时,才能确认最终结果。
更新 2:我可以运行软件并使用命令提示符生成输出文件,如下所示:
**“path\mx200810.exe” –f file.dat**
此命令读取报告参数文件并生成输出文件:
“路径\report.exe” -f Report.rwd -o Report.rwo
最新编辑:
1)我能够运行该软件,避免提示按回车键并通过以下命令使用Matlab生成输出文件:
system('report.exe /f Report.rwd /o Report.rwo')
system('mx200810.exe -f file.dat')
但是,只有在将所需的 .exe 和 .dll 文件复制到拥有 .dat 文件的同一文件夹中之后,我才能做到这一点。所以我通过我拥有所有这些文件的同一个文件夹运行 .m 文件。
2) 但是,Matlab 的命令窗口中仍然存在一个错误,上面写着:
"...STOP: Unable to open the following file as data file:
'file.dat'
Check path name for spaces, special character or a total length greater than 256 characters
Cannot find data file named 'file.dat'
Date and Time of End of Run: .....
ans = 0"