Change table variable dimension

조회 수: 6 (최근 30일)
Soo Mee Kim
Soo Mee Kim 2019년 2월 17일
댓글: Peter Perkins 2019년 2월 18일
I have two multi-diemnsional array to be merged into a Table.
A : K x M x N x L array
B : K x M x N array
If I do table(A,B), it resulted in two columns with K rows as follows
Var1 Var2
--------------------- -------------------------
[1xMxNxL single] [1xMxN categorical]
...
I want to reduce the first dimension of each table element like
Var1 Var2
--------------------- -------------------------
[MxNxL single] [MxN categorical]
...
How to get the table?

답변 (2개)

Image Analyst
Image Analyst 2019년 2월 17일
Not sure - I'd have to try some things with either table(), permute, or squeeze(). Look up squeeze and permute() in the help and experiment with some things. You might have to permute the K dimension to the end (last dimension). How many rows are there in the table?
  댓글 수: 1
Soo Mee Kim
Soo Mee Kim 2019년 2월 18일
Table has 25377 rows.
when I try to apply squeeze or permute,
X{1,1} = squeeze(X{1,1})
or
X{1,1} = permute(X{1,1}, [2 3 4 1])
I got an error message of 'height mismatch between new assignment and the table.
I don't know how to change the diemension of each variable in the table like 1xMxNxL to MxNxL.
Thanks.

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


Peter Perkins
Peter Perkins 2019년 2월 17일
You have created an Kx2 table, one of whose variables is KxMxNxL, the other is KxMxN. I don't know if that's what you intended, or if it's useful, or if you are lokking for something else. When you see things like [1xMxNxL siingle] (which obviously is not the actual output, it would help to see what you really get), it's just a display artifact. Var1 is stored in the table as a KxMxNxL array.
If you literally want an MxNxL array and a MxN array in each row of the table, you will need to split those numeric arrays into two Kx1 cell arrays, the first of which has an MxNxL array in each cell, the other an MxN array.
But it's not clear what you actually want.
  댓글 수: 2
Soo Mee Kim
Soo Mee Kim 2019년 2월 18일
Actucally, Var1 and Var2 are MxNxL and MxN images, respectively.
I want to feed the table (dataset) into trainNetwork function.
But when I input the table into the function, I gote an error of unexpected size of images. The trainNetwork function can treat 3D or 2D images, but the table has 4D and 3D dimensions. So to feed the table into the function, I need to squeeze the unnecessary first diemension of each element in the table. That's waht I want to do.
Thanks.
Peter Perkins
Peter Perkins 2019년 2월 18일
If this
"A : K x M x N x L array
B : K x M x N array
If I do table(A,B)"
is true, then no, they are not. They are KxMxNxL and KxMxN, even inside the table.

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

카테고리

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

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by