extracting a subarray from an array is simple:
a = 1:10;
a(4:8) %returns elements 4-8.
but sometimes, I have a function that returns an array, but I only want a subset of that array:
a = foo(x,y,z);
b = a(2,9:end);
Here 'a' is a temporary variable, polluting my workspace. Hence subarray:
b = subarray(foo(x,y,z),2,'9:end');
SUBARRAY should handle all the normal indexing cases (output of FIND, ranges, unspecified dimensions) just like the first example. The only exception is the 'end' keyword, where we have to pass in a string and EVAL it.
I tip my hat to Garret Euler of SUBMAT and SUBMAT_NOEVAL.
인용 양식
Peter Mao (2026). subarray (https://kr.mathworks.com/matlabcentral/fileexchange/24457-subarray), MATLAB Central File Exchange. 검색 날짜: .
MATLAB 릴리스 호환 정보
개발 환경:
R2009a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux카테고리
Help Center 및 MATLAB Answers에서 Matrices and Arrays에 대해 자세히 알아보기
