代码之家  ›  专栏  ›  技术社区  ›  b3.

枚举数组中缺少值

  •  0
  • b3.  · 技术社区  · 6 年前

    对于其他数据类型,我们可以使用NaN或missing。使用此示例枚举类:

    classdef MyEnum
       enumeration
          A
          B
       end
    end
    

    我试过:

    >> [ MyEnum.A MyEnum.B missing ]
    Error using horzcat
    The following error occurred converting from missing to MyEnum:
    Unsupported conversion from 'missing' to enumeration 'MyEnum'.
    
    >> [ MyEnum.A MyEnum.B NaN ]
    Error using horzcat
    The following error occurred converting from double to MyEnum:
    Cannot call the constructor of 'MyEnum' outside of its enumeration block.
    

    我好像错过了一些基本的东西。。。请帮帮我!

    1 回复  |  直到 6 年前
        1
  •  0
  •   YoniChechik beardhatcode    6 年前

    有两种方法: