Is it possible to manipulate a single field within a 'UserData' structure of a figure or axis ???

4 views (last 30 days)
We have used the 'UserData' property of a MATLAB figure's axes to store various data. That's why we have chosen to define 'UserData' as a structure.
Because we have stored a considerable amount of data within the structure, we would like to avoid manipulating single fields with get/set commands which can only access the 'UserData' property as a whole (as far as I know). Manipulating as a whole is time consuming.
Does anybody know a way to manipulate the single fields of the structure directly?
Many Thanks
Ulrich
  1 Comment
Matt Raum
Matt Raum on 6 Jan 2016
Ulrich,
I'd love to know if you found any answers to this because I have exactly the same problem.
I develop GUI's which sometimes need to store a large amount of data internally and I do this by making the 'userdata' property a structure. The problem is that in order to pull one small field I am forced to first assign the 'userdata' property value to another variable from which I can access a single field. If the 'userdata' structure also contains large data fields then the assignment (and therefore the time to access even a small data field) is very time consuming.

Sign in to comment.

Answers (1)

Walter Roberson
Walter Roberson on 6 Jan 2016
No. But see getappdata() / setappdata(), which in essence allow you to work at the struct field level.
You should also be considering storing the handles to objects instead of the objects themselves, as pulling back a struct filled with handles and accessing one of the handles is going to be much faster than pulling back a struct filled with the content of everything.
  2 Comments
Matt Raum
Matt Raum on 6 Jan 2016
Thanks for the good advice Walter, these fit the bill perfectly. My new implementation using these functions is much snappier than my old one.
Kulbhushan Chand
Kulbhushan Chand on 19 Apr 2018
Edited: Kulbhushan Chand on 19 Apr 2018
I am not able to figure out how to use the setappdata() to modify only a particular field in a structure (as asked in the question). What should be the correct syntax?

Sign in to comment.

Categories

Find more on Interactive Control and Callbacks in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!