Is there a way to store original structs in a cell array?
3 次查看(过去 30 天)
显示 更早的评论
Hello, I am trying to design an application and I want to change "Enable" property of some spinners according to user input. However, I have 30 spinners in my app and I do not want to write if or switch conditions for every possible input, so I considered storing spinners in a cell array by writing get(app.Spinner). It did not work because (I think- I am new to programming) a copy of the object is assigned into cell array. Therefore, I am asking this if storing an original object is available or is there any different approach that I can achieve my goal. Any help appreciated.
0 个评论
采纳的回答
Walter Roberson
2020-12-1
When you ask to get(app.Spinner) you are asking for the public properties of app.Spinner to be fetched. Most object properties are not handle objects, so you mostly get data such as 'on' or coordinate vectors.
Properties that happen to be handle objects will have the handle being saved. MATLAB is not deliberately making copies of the contents of handle objects.
If you want to locate graphic objects with a particular property, use findobj()
3 个评论
Walter Roberson
2020-12-2
findobj locates objects and returns handles to them. You can then query their properties.
get() fetches properties but has to be told where it is fetching from.
figs = findobj(groot, 'type', 'figure')
%figs is just handles
n = get(figs, 'name')
%n will now be a cell array of figure names
%unless only one figure was found. Then
%n would be the figure name directly
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Object Programming 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!