Class Property Validation for the Contents of a Cell Array Property?
I’m writing a class that stores its data in the form of cell arrays, matching values to their units. An example property definition might look something like:
classdef myClass
properties (SetAccess = private)
prop1 (2, 2) cell = { 1000, "m" ; 1, "km" }
end
end
In the class definition, I’d like to use property validation to restrict the values in column 1 to valid distances, nonnegative for example, and column 2 to valid strings that define an actual unit type, "m"/"ft"/"in" for example. This is trivial for defined types, like ‘int16’ or ‘double’, but I’m wondering if anyone has accomplished this for columns/rows inside a cell array. The goal here is to store property value with its unit, while also restricting both to valid input. Is this possible given the cell type at property definition? Thanks!I’m writing a class that stores its data in the form of cell arrays, matching values to their units. An example property definition might look something like:
classdef myClass
properties (SetAccess = private)
prop1 (2, 2) cell = { 1000, "m" ; 1, "km" }
end
end
In the class definition, I’d like to use property validation to restrict the values in column 1 to valid distances, nonnegative for example, and column 2 to valid strings that define an actual unit type, "m"/"ft"/"in" for example. This is trivial for defined types, like ‘int16’ or ‘double’, but I’m wondering if anyone has accomplished this for columns/rows inside a cell array. The goal here is to store property value with its unit, while also restricting both to valid input. Is this possible given the cell type at property definition? Thanks! I’m writing a class that stores its data in the form of cell arrays, matching values to their units. An example property definition might look something like:
classdef myClass
properties (SetAccess = private)
prop1 (2, 2) cell = { 1000, "m" ; 1, "km" }
end
end
In the class definition, I’d like to use property validation to restrict the values in column 1 to valid distances, nonnegative for example, and column 2 to valid strings that define an actual unit type, "m"/"ft"/"in" for example. This is trivial for defined types, like ‘int16’ or ‘double’, but I’m wondering if anyone has accomplished this for columns/rows inside a cell array. The goal here is to store property value with its unit, while also restricting both to valid input. Is this possible given the cell type at property definition? Thanks! cell arrays, property validation MATLAB Answers — New Questions