フィルターのクリア

put each column of a matrix into different cells

12 ビュー (過去 30 日間)
ARN
ARN 2020 年 5 月 11 日
編集済み: Mehmed Saad 2020 年 5 月 11 日
I have a matrix of size (4x4)
a = [1 2 3 4; 123 4 5 6; 52 5 4 7; 2 5 8 7];
b = mat2cell(a, ?)
I want b to be a {4x1} or {1x4} cell where every cell contains the column values of matrix
b = cell{1,:} = [1; 123; 52; 2] , cell{2,:} = [2 ; 4 ; 5 ; 5] and so on. but i am not being able to figure out mat2cell input parameters

採用された回答

Mehmed Saad
Mehmed Saad 2020 年 5 月 11 日
編集済み: Mehmed Saad 2020 年 5 月 11 日
Use num2cell. it is easy
a = [1 2 3 4; 123 4 5 6; 52 5 4 7; 2 5 8 7];
b = num2cell(a,1)
b =
1×4 cell array
{4×1 double} {4×1 double} {4×1 double} {4×1 double}

mat2cell

is usefulll for other purpose
b = mat2cell(a.',[1 1 1 1])
b =
1×4 cell array
{4×1 double} {4×1 double} {4×1 double} {4×1 double}

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMultidimensional Arrays についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by