I'm asking this question to test a concept. I'm not trying to have a solution presented in code, I simply need advice as to what direction to continue.
I would like to make a structure field that is always a function of other fields of the same structure.
I have been able to implement code that can modify the existing structure and update it with a new field. But this doesn't work without re-initializing a code this is not ideal.
I need the ability to add another structure, give it values for certain fields, then automatically update the rest of the fields via functions I have defined.
Is a structure even the right method to accomplish this task? I think it isn't but I am not sure what method can be used.
I've attached a very simple code snippet to demonstrate the problem.
module = struct('dim', [ 3 1 0.05], ...
'point', [0 0 0], ...
'shape', cubeshape(module.dim,module.point))
% cubeshape is my function of dim & point
matlab returns an error....
Undefined function or variable 'dim'.
this makes sense because the struct() function has not yet been closed which means that the module struct has not yet been defined.
If my question is too novice, please just tell me I can continue to research, but some guidance would be appreciated.
Thanks!