How to navigate through Struct/Cell from Matlab Gui?

6 次查看(过去 30 天)
Dear Community,
I have a GUI which can load data from the workspace. Like the Curve Fitting App from Matlab I can read arrays with a pop up menu and use the data. Yet, if my data is a struct or cell, I would like to navigate through that and select my choice of data.
I was thinking of a pop up menu which detects if it is a struct/cell and than has a arrow to the right to go one step deeper. Comparable to a normal windows start button menu, where the content can be reached by continuing the path given when there is an arrow.
Has anyone any idea how to realize such thing in Matlab, or a different way to navigate to the data if in struct/cell from a Gui?
Thanks Ravi

回答(2 个)

Evan
Evan 2014-8-19
编辑:Evan 2014-8-19
For determining the datatype of the arrays selected by the user, see the iscell and isstruct functions. The who command can allow you to obtain the names of the variables in your workspace. Or, if you're using the handles structure, fieldnames can do the equivalent.
  4 个评论
Ravi Goyal
Ravi Goyal 2014-8-19
Well yes kind of. I want to be able to select certain data from a struct/cell. Through performing large measurements, data sets are created and all nicely sorted in a cell. To load specific data from one measurment into a gui, I would like to select which cell content to use.
This is possible from the Workspace of matlab to navigate through the cells/struct, but I dont know how to implement or use such navigation from within a GUI...
Evan
Evan 2014-8-19
编辑:Evan 2014-8-19
If you are wanting to display individual cells/fields, I would suggest allowing the user to specify a field/row & column based on their cell/struct selection, and that could then be displayed in an edit box. If you want to look at the entire selected cell/struct, I would suggest displaying it in a uitable on your GUI.
Are the data you're using (whether they be cells, structs, etc.) stored in the handles structure when loaded/created? I would suggest this, especially if you're using GUIDE to create your GUI.

请先登录,再进行评论。


Ravi Goyal
Ravi Goyal 2014-8-20
The Cells contain lots of data normally and can be structured differently. So, I feel a uitable could not display everything properly. My GUI is made with GUIDE and I am using handles structure.
I want to get variables from the workspace of Matlab though, and with arrays its no problem. The easiest would be if the Variables Field which opens if you double click a variable from the workspace could be used somehow or implemented as GUI or assigned the handles of my gui.
Who works nicely, yet only gives me the Variable name of the whole cell. Sth like uitree or similar also looks promising yet there is nothing official so a user could select data from within a cell/struct? Any further suggestion maybe? Thanks a bunch

类别

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