How to immediately pick an index from a result that is a matrix.
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Jan
il 3 Lug 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Matrix Indexing in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!