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 
  • 相关阅读:
    oracle 体系结构
    Oracle存储过程语法
    oracle 触发器
    oracle 存储过程
    oracle 高水位线详解
    oracle索引总结
    Oracle的表空间、数据文件、用户
    Oracle实例和数据库区别
    [whu1564]后缀数组
    [hdu4552]最长公共前缀
  • 原文地址:https://www.cnblogs.com/mtcnn/p/9422517.html
Copyright © 2011-2022 走看看