MATLAB Answers


import struct as property in App Designer

Asked by ChiPhi85 on 6 Jan 2019
Latest activity Commented on by ChiPhi85 on 10 Jan 2019
I'd like to load a struct as a .mat file into my app, input values and then save changes. I'd like to import it as a property. I can do it using:
properties (Access = private)
And then loading it on startup:
function startupFcn(app)
myStruct = load('DemoStruct.mat');
This works and I am able to edit and save the struct, but I don't get the option of autocomplete when using app.myStruct. as a way to access the fields in the struct. Is there any way to do this? The only way I can get it to work is by manually typing and this is a pain when there are many fields and indexes at play.


Sign in to comment.

1 Answer

Answer by Prajith Chilummula on 10 Jan 2019

The autocompletion completion uses static analysis, so the variables won’t be completed unless defined in the workspace. During editing, the field names of a struct are not known as they are unavailable in the workspace. Therefore you cannot access the members of the struc variables. But autocomplete can be used while debugging the program. A static code analysis might be misleading also, because fields can be created dynamically also.

  1 Comment

Is there no way to load the struct into the workspace from the app?

Sign in to comment.