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

조회 수: 1 (최근 30일)
Berkay Yaldiz
Berkay Yaldiz 2020년 12월 1일
댓글: Berkay Yaldiz 2020년 12월 2일
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.

채택된 답변

Walter Roberson
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
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
Berkay Yaldiz
Berkay Yaldiz 2020년 12월 2일
Thank you, I understand it.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Graphics Object Identification에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by