Why is UserData preferred over guidata
Show older comments
Storing app data in the UserData property of the main app figure is recommended over using guidata, because it can result in more readable code. For more information about storing and sharing app data, see Share Data Among Callbacks.
I do not understand why UserData results in more readable code. For example, extracting data from the UI in a callback is with guidata:
data = guidata(gobject);
and with UserData:
data = ancestor(gobject, "figure", "toplevel").UserData
What are the benefits of UserData over guidata and does it matter which one you use?
Accepted Answer
More Answers (0)
Categories
Find more on Structures 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!