I have a class defintion which makes use of OOP dynamicprops and I've noticed some odd behaivor in accessing the properties.
classdef myClass < dynamicprops
function this = myClass(x)
this.x = x;
If I add new properties to the class in a script which looks something like this
hObj = myClass(10);
fn = fieldnames(hObj)'
I was expecting the properties to be added to hObj in the same order that they are scripted in, but I find that the properties added to hObj do not get added in any consistent way. EVERY TIME I run the script, hObj is returned with a different order in the properties ?! Can anyone explain why these dynamic properties behave in such a stranage way? Is there no way to control the order in which these properties appear in the object?
It would be nice if I could control the order so that a function call like fieldnames(hObj) would return values in a predictable way. As a secondary but also irksome issue there appears to be no way to REMOVE a dynamic property once it has been added?!
... here is the output from 5 runs of the script I show above in R2010b:
'x' 'b' 'a' 'c' 'd' 'e'
'x' 'd' 'e' 'a' 'c' 'b'
'x' 'd' 'a' 'b' 'e' 'c'
'x' 'b' 'd' 'a' 'c' 'e'
'x' 'b' 'a' 'd' 'c' 'e'