Change table variable dimension

5 次查看(过去 30 天)
Soo Mee Kim
Soo Mee Kim 2019-2-17
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