Hi,
I have a conceptual problem I'm struggling with and was wondering if anyone could give some insight into this.
Essentially, I have a class with three (or more) properties. Watered down Pseudo code below:
classdef obj Properties A B C end Methods constructor etc function set.A C = f(obj.A,obj.B) % C is dependent on A and B (MLINT warns on this line)
A = inputValue % Set A's value
end end end
Now herein lies the problem as I'm sure you have already noticed. I'm setting one properties value while changing another property's value. MLINT warns immediately that this is bad and correctly states that one should make C a dependent property.
This is fine unless speed is an issue. C is going to be called "lots of times". And having Matlab calculate it every time
*get.C*
is called is expensive. A and B will be updated through out the life of the object and hence I want C recalc'ed on the fly when they do.
Should I disregard MLINT (and probably good coding practice)?
Is there a better but still fast way to achieve what I want?
Regards, Phil
Best Answer