当我运行 matlab -nodesktop -r "run myscript"
Matlab 命令窗口时,会弹出并有输出,但我希望将输出定向到 unix 控制台。那么如何让 Matlab 脚本从 Unix 控制台运行以输出到 Unix 控制台?
问问题
173 次
1 回答
2
要将数据输出到控制台(最好是标准输出),您可以使用 MATLAB 函数fprintf()并运行它:
user@host $ matlab -nodesktop -r "run new.m; quit"
新的.m:
noise_gain = 0.5;
filter_length = 128;
fprintf('*******************************************************************\n');
fprintf('** Starting processing for noise level %f and filter length %d**\n',noise_gain,filter_length);
fprintf('*******************************************************************\n');
它给出输出:
*******************************************************************
** Starting processing for noise level 0.500000 and filter length 128**
*******************************************************************
您也可以将输出发送到文件(out.txt):
user@host $ matlab -nodesktop -r "run new.m; quit"> out.txt; cat out.txt
< M A T L A B (R) >
Copyright 1984-2012 The MathWorks, Inc.
R2012b (8.0.0.783) 64-bit (glnxa64)
August 22, 2012
To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.
*******************************************************************
** Starting processing for noise level 0.500000 and filter length 128**
*******************************************************************
于 2013-11-13T17:26:46.347 回答