Lets say I have a struct or a handle object with many properties, so that calling a property with a dot is time consuming (it is done millions of times ever run)
is there a way to asign a handle to the property so that I can call it directly?
Nathan

 채택된 답변

Rik
Rik 2023년 3월 14일

0 개 추천

The only way I can think of is to make that property contain an object of a handle class. Other than that, no, because you can only directly refer to objects, not to their properties.
If the indexing is the problem, why not store the value in a variable? I can't imagine any user interaction generating changes millions of times.

댓글 수: 4

Thank you for your answer Rick. The changes are related to events and listeners. At some point during the run we need to call:
Data.AffectedObject.(Source.Name)
To retrieve the value of a changed property. the listeners are trigerred on the fly and are therefore called many tiimes during the run.
would be happy for a workaround
Nathan Blanc
Nathan Blanc 2023년 3월 16일
BTW the problem occurs because we do not have anything similar to linkprop for objects that are not graphic objects. if there was something like this it would also solve our problem
Rik
Rik 2023년 3월 16일
편집: Rik 2023년 3월 16일
Perhaps a persistent variable to create a makeshift dictionary would do the trick?
That way you can use ismember to look up the index in your cached data. You can even implement a counter that refreshes your data every X times.
Also, what do you think the chances are that I made a typo in my own name?
Nathan Blanc
Nathan Blanc 2023년 3월 18일
Thank you again for your answer Rik :)
Your answer looks like a good workaround, albeit a bit dirty. I will try it
Nathan

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2023년 3월 14일

댓글:

2023년 3월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by