How to immediately pick an index from a result that is a matrix.

4 次查看(过去 30 天)
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

采纳的回答

Jan
Jan 2012-7-3
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 个)

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by