How to immediately pick an index from a result that is a matrix.
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a small issue which I stumble upon quite often.
Is it possible to immediately select a certain index if the result is a matrix.
For example, if I have a matrix stored under the Data of a uitable, and i want to retrieve it using get, and then take a certain index from it, my current method is like this:
para=get(handles.uitable6,'Data');
Calpha=para(5,1)
However, this requires for the creation of an additional matrix (in this case para), which might increase computing time for very late matrices. Is it possible to immediately pick one of the values from a matrix, thus preventing the creation of an additional matrix.
Thanks in advance,
Roy
0 comentarios
Respuesta aceptada
Jan
el 3 de Jul. de 2012
This feature has been requested repeatedly, see: http://www.mathworks.com/matlabcentral/answers/1325#answer_1931
The line
para = get(handles.uitable6,'Data');
does not need a noticable amount of time, becauseit does not crate a new array and copy the data, but it is a "shared copy": only a new header for the variable is created, but the actual data are shared using a pointer to the same memory.
Therefore your posted code is efficient related to memory and processing time. The direct indexing would be "nicer" only.
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!