subarray

バージョン 1.1.0.0 (1.46 KB) 作成者: Peter Mao
Extracts a subarray from an array. Useful for function outputs.
ダウンロード: 834
更新 2011/8/1

ライセンスの表示

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://jp.mathworks.com/matlabcentral/fileexchange/24457-subarray), MATLAB Central File Exchange. に取得済み.

MATLAB リリースの互換性
作成: R2009a
すべてのリリースと互換性あり
プラットフォームの互換性
Windows macOS Linux
カテゴリ
Help Center および MATLAB AnswersMatrices and Arrays についてさらに検索
バージョン 公開済み リリース ノート
1.1.0.0

prev version wasn't handling 1xn matrices in the expected way (it wasn't skipping the singeton dimensions). usage in functions seems to be well behaved now, provided one uses quotes around :'s and "end"'s

1.0.0.0