Handle to a Property or field

1 回表示 (過去 30 日間)
Nathan Bblanc
Nathan Bblanc 2023 年 3 月 14 日
コメント済み: Nathan Bblanc 2023 年 3 月 18 日
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 日
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 件のコメント
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 Bblanc
Nathan Bblanc 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 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by