zoukankan      html  css  js  c++  java
  • 【Matlab】利用diary记录日志/保存命令窗口输出

    matlab 中可以利用diary函数记录下命令行窗口的输出到指定文件中,方便后期检查调试和运行信息。

    diary

    diary是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

  • 相关阅读:
    Java 多线程系列02
    Java 多线程系列01
    java io流03 字符流
    java JDBC系列
    java io流02 字节流
    Helidon使用心得
    camel 解析
    Spring 源码分析
    java代码实现分页功能
    SpringBoot Tomcat启动报错
  • 原文地址:https://www.cnblogs.com/Tom-Ren/p/10234989.html
Copyright © 2011-2022 走看看