Is there a way to store original structs in a cell array?

1 Ansicht (letzte 30 Tage)
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.

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 1 Dez. 2020
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 Kommentare
Walter Roberson
Walter Roberson am 2 Dez. 2020
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
Berkay Yaldiz
Berkay Yaldiz am 2 Dez. 2020
Thank you, I understand it.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Graphics Object Identification finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by