Map a matrix 300 cells of matrices to a 2d matrix

4 ビュー (過去 30 日間)
Sam R
Sam R 2017 年 11 月 20 日
編集済み: KL 2017 年 11 月 20 日
I have a matrix M1 of size 1x300, which contains in each column, on the first and only row a cell with a matrix of size 28x28.
I want to convert each 28x28 matrix to a column vector and store them all as columns in a new matrix, so that the i-th column of the resulting matrix will represent the i-th column of the original matrix, but instead of cells with matrices, I'll have column vectors representing the smaller matrices.

採用された回答

KL
KL 2017 年 11 月 20 日
編集済み: KL 2017 年 11 月 20 日
dummy = repmat({reshape(1:784,28,28)},1,300);
C = cell2mat(cellfun(@(x) [x(:)],dummy,'uni',0));
or simpler,
C = reshape([dummy{:}],28*28,[]);

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by