mustBeMember validation problem failure

10 ビュー (過去 30 日間)
RST
RST 2023 年 10 月 26 日
編集済み: RST 2023 年 10 月 26 日
This class fails property validation on construction
classdef validationTester
properties
coupling (1,:) char {mustBeMember(coupling,{'DC', 'AC'})} = 'DC'
end % public properties
end % classdef
with message
>> vt = validationTester
Error setting default value of property 'coupling' of class 'validationTester'. Value must be a
member of this set:
'DC'
'AC'
Why is this?

採用された回答

RST
RST 2023 年 10 月 26 日
編集済み: RST 2023 年 10 月 26 日
Self answer.
The char array is being forced into a column vector not the intended row vector. We want the size to be constrained to (1,:) not (:,1).
We should have:
classdef validationTester
properties
coupling (1,:) char {mustBeMember(coupling,{'DC', 'AC'})} = 'DC'
end % public properties
end % classdef

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeArgument Definitions についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by