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 CenterFile Exchange에서 Properties에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by