How to immediately pick an index from a result that is a matrix.
조회 수: 1 (최근 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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!