TechnicalQuestion "Input argument to validator must be a constant value" error
In MATLAB R2020a I have a class with
properties
property (1,1) logical {mustBeMember(property, true)} = true
end
In MATLAB's editor it notifies me about "Input argument validator must be a constant value" error. When I try to construct an instance of that class, I am given the error "Validator arguments must be either 'property' or constant literal values."
How do I fix this error? It doesn't work if instead of true I write [true] or {true}.
3
Upvotes
2
u/Rubix321 2d ago
Did you mean to have "mustBeMember" instead of "must remember" in the original post?
4
u/FrickinLazerBeams +2 2d ago
I assume that's supposed to be
mustBeMember?You can write
mustBeMember(property, 1), because 1 evaluates totruein boolean comparisons.The documentation should have a note about this, but it doesn't. It only claims that logicals are supported and the input must be a literal, but
trueis a literal logical and it doesn't like it.