Matlab class properties have the following two limitations which are relevant to my problem,
- Dependent properties cannot store values
- setter for Properties (normal properties with no specified attributes, access specifiers, etc) cannot access other properties.
In my scenario, I need a workaround which will allow me to have a dependent property which can also store value. The dependence on another property is only for a conditional statement and not for assigning it's value with the other property itself. This scenario is illustrated by the code snippet given below, which is also my requirement that Matlab does not allow.
classdef foo
properties
a
b
end
properties (Dependent = true)
c
end
methods
function this = foo(c_init)
a = 1;
b = 1;
this.c = c_init;
end
function this = set.c(this,value)
if b==1
c = value;
else
c = 1;
end
end
function value = get.c(this)
value = this.c;
end
end
end
Is there any workaround for the above?