Access to properties of an object array element

조회 수: 3 (최근 30일)
Tomas  Domaschke
Tomas Domaschke 2011년 3월 17일
편집: Leepakshi 2025년 6월 16일
I've got an object which contains an object array as a property. This objcet array consists of around 100k - 1 mio elements. It takes more than 1 sec to access a property of one of the elements in the array .
This is my code
Object.ObjectArray(x).property= Object.ObjectArray(x).property + Y
I hope that I am doing something wrong
Thanks for the help
Maaschn

답변 (1개)

Leepakshi
Leepakshi 2025년 6월 3일
편집: Leepakshi 2025년 6월 16일
Hi Tomas,
If accessing a property in a large object array is slow, it is likely due to factors like lazy loading, proxy objects, or complex getters. To speed it up, cache the element in a local variable
e.g.,
elem = Object.ObjectArray(x);
elem.property = elem.property + Y;
and ensure you are working with a plain array. Profiling the code can help identify hidden bottlenecks.
Hope that helps!
  댓글 수: 1
Steven Lord
Steven Lord 2025년 6월 3일
The code you've posted is not valid MATLAB code.

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

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by