フィルターのクリア

Extracting a column vector from a 3D matrix

2 ビュー (過去 30 日間)
Tommy
Tommy 2014 年 3 月 18 日
コメント済み: Tommy 2014 年 3 月 18 日
Hi
I have a 3D matrix (A) with dimension of (10,10,320).
If I label the column vectors(320,1) with 1 - 100, I will get 100 column vectors with dimension of (320,1).
My question is that if there is a way to extract or find out one specific column vector from the 3D matrix if I have the index number between 1 and 100.
For example, if I know the index number is 10, I will look for the elements which situate at (10,1,:) of the 3D matrix (A). But is there a way to ask MATLAB to do it?
Thank you very much
Tommy

採用された回答

Andrei Bobrov
Andrei Bobrov 2014 年 3 月 18 日
編集済み: Andrei Bobrov 2014 年 3 月 18 日
l = 10;
s = size(A);
[ii,jj] = ind2sub(s(1:2),l);
out = A(ii,jj,:);
other way
C = zeros(size(A));
C(l) = 1;
out = A(cumsum(C,3) > 0);
  1 件のコメント
Tommy
Tommy 2014 年 3 月 18 日
Hi Andrei
Thank you very much for your help.
This works perfectly.
Thanks
Tommy

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by