How do I retrieve individual elements from an object all at once?
Mostrar comentarios más antiguos
Hi all,
I have an Object where I'd like to retrieve all elements at once instead of through a loop.
My object is set up like this:
ObjArr
# Item one First Name
# Item two Last Name
Instead of using code like this...
for k = 1:n
tempSTR{k} = ObjArr(k).Name;
end
...I'd like to use something like the code below to quickly pull out a vector of data across all elements.
tempSTR{} = ObjArr.Name;
Please help.
Thanks,
jason
Respuesta aceptada
Más respuestas (1)
Daniel Shub
el 13 de Jul. de 2012
0 votos
Loren's blog has a post about OOP performance. Looping outside the object is slower than looping inside the method. You probably want to overload SUBSREF and get.Name to handle arrays.
Categorías
Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!