0

i'm trying to write a save/load function for an app with a bunch of properties in matlab. The saving works fine, but i'm having sum issues with loading. The bit i'm having trouble with is this:

loadlist=['app.starting_height','app.dragenabled','app.heading'...];
        n=1;
        for(n=1:length(loadlist))
            loadlist(1,n)=savelist(1,n);

What i want to do is instead of changing the values in loadlist (loadlist(1,n), change the properties they reference (app.startingheight, etc). I have an idea to try and use handles, but I'm not quite sure how that would work. Any help would be appreciated.

Thanks!

1 Answers1

0

You can generate field names from variables, so something like this:

loadlist=["app.starting_height","app.dragenabled","app.heading"...];

for elem = loadlist
  field_names = split(elem, '.');
  app.(fieldnames(2)) = ...

should work.

PRa
  • 16
  • 1