0
我需要定義一個稱爲MobileBaseStation類和被叫DataChannel屬性,它是一個結構如下所示,製作一個結構屬性的字段作爲類的屬性在Matlab
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
的制定者需要強制DataChannel結構的字段的邊界/限制。我希望結構的字段是MobileBaseStation類的屬性,以便我可以使用setter。我如何在Matlab中實現這一點?
創建'DataChannel'一個新的類,並作出這樣的類的屬性你的'MobileBaseStation'類 –