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

4 次查看(过去 30 天)
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!

采纳的回答

Adam
Adam 2017-6-22
编辑:Adam 2017-6-22
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by