【Matlab】利用diary记录日志/保存命令窗口输出 |
您所在的位置:网站首页 › matlab里面log函数 › 【Matlab】利用diary记录日志/保存命令窗口输出 |
matlab 中可以利用diary函数记录下命令行窗口的输出到指定文件中,方便后期检查调试和运行信息。 diarydiary是matlab中的日志工具,可以将Command Window 中的内容保存到文件中去。使用方法: 在命令行中输出: diary 'path/yourlogfile.txt' 对应的的文件将会保存在path路径下的yourlogfile.txt文件里。 同时,可以使用: diary off,diary on命令来关闭、打开日志。 %diary使用例子 >> diary 'mylog.txt' %打开日志记录命令窗口 >> disp('add this into mylog') add this into mylog >> 1+1 ans = 2 >> diary off %关闭了日志,不再记录 >> disp('this will not log') this will not log >> diary on %重新打开日志记录 >> disp('this will be log') this will be log >> disp('this will be log') this will be log >> diary off %关闭,保存记录在mylog.txt文件中就可一看到打开日志的几段命令和输出: 注意:结束时,需要利用diary off命令来结束日志,以便关闭文件保存日志。 pic from pixels.com |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |