zoukankan      html  css  js  c++  java
  • matlab 警告(warning)、错误(error)、异常(exception)与断言(assert)

    0. 消息标识符(Message Identifiers)

    消息标识符,是附加在 error 和 warning 语句上的一个标签,以被 matlab 做唯一性标识。

    warning 语句所支持的函数重载中,便可接收消息标识符,以警告信息的形式进行在控制台输出:

    warning(msgID, ___)

    一个简单的标识符的格式为:component:mnemonic,用冒号隔开;

    matlab 内置的消息标识符为:

    MATLAB:rmpath:DirNotFound
    MATLAB:odearguments:InconsistentDataType
    Simulink:actionNotTaken
    TechCorp:OpenFile:notFoundInPath

    1. warning(警告)

    warning('off', '*:*:*');

    2. 异常

    try,catch

    A = rand(3);
    B = ones(5);
    
    try
       C = [A; B];
    catch ME
       if (strcmp(ME.identifier,'MATLAB:catenate:dimensionMismatch'))
          msg = ['Dimension mismatch occurred: First argument has ', ...
                num2str(size(A,2)),' columns while second has ', ...
                num2str(size(B,2)),' columns.'];
            causeException = MException('MATLAB:myCode:dimensions',msg);
            ME = addCause(ME,causeException);
       end
       rethrow(ME)
    end 
  • 相关阅读:
    stdin stdout stderr
    stat
    ssh-keyscan
    START TRANSACTION
    ssh-keygen
    ssh-agent
    ssh-add
    虚拟化之lxc
    Web 在线文件管理器学习笔记与总结(1)初始文件以及获取首层目录信息
    Java实现 LeetCode 97 交错字符串
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9422517.html
Copyright © 2011-2022 走看看