How to convert 4D double matrix into 2D arrays

조회 수: 8 (최근 30일)
Sung Wook Choi
Sung Wook Choi 2023년 11월 13일
댓글: Dyuman Joshi 2023년 11월 15일
Hi
I'm sorry for my English :(
I'm trying to convert 4-D double matrix into 2D arrays
There are a total of 14 different scenarios, each represented by a matrix of size 1x101 in the program. The representation in 4D is structured as (:,:,1,1) through (:,:,101,1) for the first scenario, (:,:,1,2) through (:,:,101,2) for the second scenario, and so on, up to (:,:,1,14) through (:,:,101,14) for the fourteenth scenario. Each set of indices within the 4D structure corresponds to a unique value in the respective scenario.
Thank you so much
  댓글 수: 8
Dyuman Joshi
Dyuman Joshi 2023년 11월 13일
Yes, that's what I meant.
Ok, there are 2 singleton dimensions.
Now, What is the output you want? A 101x14 array?
Sung Wook Choi
Sung Wook Choi 2023년 11월 13일
Yes I want it!

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

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 11월 13일
Use squeeze -
in = rand(1,1,101,14);
size(in)
ans = 1×4
1 1 101 14
out = squeeze(in);
size(out)
ans = 1×2
101 14
  댓글 수: 10
Sung Wook Choi
Sung Wook Choi 2023년 11월 15일
Thank you so much! Finally, may I ask what the difference is between the 'out1' and 'out2' matrices? They appear to be the same, and I couldn't identify any distinctions.
Also, when you use 'squeeze,' it removes two singletons. Does 'squeeze' mean removing all singletons in a matrix?
Dyuman Joshi
Dyuman Joshi 2023년 11월 15일
You are welcome!
Yes, they are the same.
For the second one, I have just combined all the steps in one command.
Yes, 'squeeze' removes all the singleton dimensions of an array.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by