代码之家  ›  专栏  ›  技术社区  ›  Amarth Gûl

在Matlab中调用一个类作为另一个类属性的方法

  •  0
  • Amarth Gûl  · 技术社区  · 6 年前

    如果标题令人困惑,请道歉。

    我试图将一个类的属性设置为另一个类:

    classdef gun
        properties
            bullets;
            ...
    

    哪里 bullets 之后初始化为另一个类对象 bullets = bul(10);

    classdef bul
        properties
            ...
        methods
            function obj = addBullet(obj, num)
                ...
    

    但当我试图调用 addBullet 在课堂上 gun 喜欢 gun.bullets.addBullet(2) ,我犯了一个错误,说:

    Dot indexing is not supported for variables of this type.
    

    是因为Matlab不支持类作为另一个类的属性吗?我能修好吗?

    0 回复  |  直到 6 年前