How can I merge a 3 column numeric matrix into a single column cell array?

5 ビュー (過去 30 日間)
Rafael Cordero
Rafael Cordero 2021 年 12 月 1 日
回答済み: Matt J 2021 年 12 月 1 日
Hello folks,
I have the following 3-column numeric matrix:
10 20 30
10 25 35
10 30 35
10 35 40
10 45 50
... ... ...
I would like to transform it into a single column cell array where the three numbers are separated by a space:
10 20 30
10 25 35
10 30 35
10 35 40
10 45 50
... ... ...
The idea is that I will then use this cell array as an xlabel for a plot I have.
BONUS: if instead of the space separating each number I could have a newline (to facilitate visaulization of the xlabel in the plot), it would be awesome!
Thank you!

採用された回答

Matt J
Matt J 2021 年 12 月 1 日
A=[10 20 30;
10 25 35;
10 30 35;
10 35 40;
10 45 50];
num2cell(A,2)
ans = 5×1 cell array
{[10 20 30]} {[10 25 35]} {[10 30 35]} {[10 35 40]} {[10 45 50]}

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSparse Matrices についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by