Matrix reshape from 3d to 2d

4 ビュー (過去 30 日間)
Boby S
Boby S 2020 年 5 月 13 日
コメント済み: Boby S 2020 年 5 月 15 日
Hi
I have 3d matrix (1*80). Each cell has diffrent rows with 4 column. I want to convert all of it to 2d matrix but I want to keep the 3d matrix dimension(column,1-80) as index for my data.
So, I need t to add a new column(3d dimension) to my new 2d matrix as 5th column.
  2 件のコメント
Walter Roberson
Walter Roberson 2020 年 5 月 13 日
1 x 80 -- do you mean you have a 1 x 80 cell array, each cell of which is a something by 4 array? Are all of those the arrays the same size? When you convert it all to 2D, what size are you expecting the output to be?
Boby S
Boby S 2020 年 5 月 15 日
yes, they are not same size. The final size will be(sum of rows,5)

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

採用された回答

Walter Roberson
Walter Roberson 2020 年 5 月 13 日
Output = cell2mat(arrayfun(@(IDX) [YourMatrix{IDX}, repmat(IDX, size(YourMatrix{IDX},1), 1)], (1:length(YourMatrix)).', 'uniform', 0));
  1 件のコメント
Boby S
Boby S 2020 年 5 月 15 日
Thanks

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by