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 
  • 相关阅读:
    Nginx的访问控制
    远程登录
    Linux的网络命令
    laravel-collect
    laravel-model
    laravel-Macroable
    laravel-容器
    机器学习-Logisitic回归
    机器学习-多变量线性回归
    算法笔记-分支界限法
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9422518.html
Copyright © 2011-2022 走看看