フィルターのクリア

How to get values in an 8x8x4096 matrix?

5 ビュー (過去 30 日間)
Ajay Ganti
Ajay Ganti 2018 年 3 月 1 日
編集済み: Andrei Bobrov 2018 年 3 月 1 日
I have a matrix of size 8x8x4096. I need to get the values of positions (1,2),(2,2),(2,1) of each 8x8 block of all 4096 such blocks into a variable "x","y","z" respectively. Means all the values at locations (1,2) of 4096 blocks in variable x and (2,2) in y and (2,1) in z respectively.

採用された回答

Andrei Bobrov
Andrei Bobrov 2018 年 3 月 1 日
編集済み: Andrei Bobrov 2018 年 3 月 1 日
Let M - your array [8x8x4096].
One variant:
[m,n,k] = size(M);
x = [1,2,2];
y = [2,2,1];
out = M(sub2ind([m,n],x(:),y(:)) + (0:k-1)*m*n)'; % MATLAB >= R2016b
% if MATLAB < R2016b then
out = M(bsxfun( @plus,sub2ind([m,n],x(:),y(:)),(0:k-1)*m*n))';
T_out = array2table(out,'v',{'x','y','z'});
  2 件のコメント
Ajay Ganti
Ajay Ganti 2018 年 3 月 1 日
thanks for the solution. It is working
Andrei Bobrov
Andrei Bobrov 2018 年 3 月 1 日
編集済み: Andrei Bobrov 2018 年 3 月 1 日
Use out(:,1) or T_out.x or just see and use variant from Stephen's answer.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by