Dynamically add a field to an object in matlab
- by Marc
Say I have a MATLAB object defined in a class file
classdef foo
properties
bar
end
end
And I create a foo object
myfoo = foo();
Now I want to add another field to foo dynamically. What I want is
foo.newfield = 42;
but this will throw an error.
I know there is a way to dynamically add a field/property to a MATLAB object but I can't remember it or find it easily in the help. Anyone know the syntax?