Is it possible to create your own structure array in a GUI that can be referenced within the GUI?

2 views (last 30 days)
I created my own structure array under a pushbutton so that I could store a lot of data collected in an organized manner. I tried referencing this structure in a subsequent pushbutton, but received an error "undefined function or variable".
  • Does anyone know if I can reference my own structure array throughout the GUI?
  • Do I need to reference it through handles?
  • Is there an easier way to do this through handles alone?
Here's a sample of some of the code:
PS(1).TLP = [fA, Ph, fFr, DF, Fr, Ds];
PS(1).Bm= [fKa, Dk, fDt, fFa];
PS(1).sp = [fp, fk, nPSe, A2, A1, A0, ScK];
This goes on and on..
Thanks!

Accepted Answer

Adam
Adam on 22 Jun 2017
Edited: Adam on 22 Jun 2017
Just add your structure to 'handles' as follows
handles.PS = PS;
guidata( hObject, handles )
then you can access it in any callback that has handles as
handles.PS
As for the question if it is easier through handles alone: No, not really. Having your own structure attached to handles is neater than piling a vast amount of raw data onto the handles struct.

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!