How to navigate through Struct/Cell from Matlab Gui?

11 views (last 30 days)
Ravi Goyal
Ravi Goyal on 19 Aug 2014
Answered: Ravi Goyal on 20 Aug 2014
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

Answers (2)

Evan
Evan on 19 Aug 2014
Edited: Evan on 19 Aug 2014
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 Comments
Evan
Evan on 19 Aug 2014
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.

Sign in to comment.


Ravi Goyal
Ravi Goyal on 20 Aug 2014
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

Community Treasure Hunt

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

Start Hunting!

Translated by