Extracting a vector from a 3d array

조회 수: 56 (최근 30일)
Graham
Graham 2014년 4월 29일
댓글: the cyclist 2023년 10월 19일
Hi, I have a 3d array called 'A' of size (l,m,n)=12x15x3648.
I want to extract all 3648 values for a given index (l,m) as a single column vector. Doing A(7,8,:) for example outputs many individual answers and is not useful. I would like them in a vector which is 3648 elements long.
Any help is appreciated. Thanks.

채택된 답변

the cyclist
the cyclist 2014년 4월 29일
편집: the cyclist 2014년 4월 29일
Two alternatives:
squeeze(A(7,8,:))
and
permute(A(7,8,:),[3 1 2])
  댓글 수: 3
Gianmarco Venditti
Gianmarco Venditti 2023년 10월 19일
Why doing something like:
X = A(:,7,8) you have vector ( a one index object)
while
X = A(7,8,:) produce a 4-D tensor? (Still have 4 index)
the cyclist
the cyclist 2023년 10월 19일
Can you upload an example of an array A where you see that happening? You can attach a MAT file using the paper clip icon in the INSERT section of the toolbar.

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

ABHIJITH U V
ABHIJITH U V 2018년 11월 20일
Hello
I would like to extract all the values 468 from a 3 d - array of size (2,2,468) into a vector. How to do this ??

Giorgio Sperandio
Giorgio Sperandio 2020년 6월 18일
Very interesting,
Would it be possible to loop the squeeze function in order to obtain the 3648 values from all the l,m indexes?
Thanks

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by