Dynamically add a field to an object in matlab

Posted by Marc on Stack Overflow See other posts from Stack Overflow or by Marc
Published on 2010-06-08T15:17:14Z Indexed on 2010/06/08 15:22 UTC
Read the original article Hit count: 333

Filed under:
|

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?

© Stack Overflow or respective owner

Related posts about matlab

Related posts about object-oriented