在Matlab

时间:2016-02-16 21:07:28

标签: matlab oop matlab-class

我需要定义一个名为MobileBaseStation的类和一个名为DataChannel的属性,它是一个结构,如下所示,

classdef MobileBaseStation
properties
    DataChannel = struct('TxScheme','SpatialMux','NLayers',4);
end
properties (Constant = true)
    supportedTxSchemes = {'Port0','TxDiversity','CDD','SpatialMux','MultiUser','Port5','Port7-8','Port8','Port7-14'};
end
methods
    function this = MobileBaseStation(this,TxSchemeChoice,NLayers)
        this.DataChannel.TxScheme = TxSchemeChoice;
        this.DataChannel.NLayers = NLayers;
    end
    function this = set.DataChannel.TxScheme(this,value)
        if ismember(value,this.supportedTxSchemes)
            this.DataChannel.TxScheme = value;
        end
    end
    function this = set.DataChannel.NLayers(this,value)
        if strcmpi(this.TxScheme,'Port8') && value==1
            set.DataChannel.NLayers = value;
        end
    end
end
end

setter需要对DataChannel结构的字段强制执行边界/限制。我希望结构的字段是MobileBaseStation类的属性,以便我可以使用setter。我怎样才能在Matlab中实现这一目标?

1 个答案:

答案 0 :(得分:0)

我认为您希望将CATiledLayer设为私有,以便您可以通过您的依赖属性getter& amp;塞特犬,例如:

DataChannel