フィルターのクリア

How can I un-nest a cell array of different type cells?

6 ビュー (過去 30 日間)
Odysseas Makariou
Odysseas Makariou 2022 年 5 月 28 日
コメント済み: Voss 2022 年 5 月 28 日
Hello, I have a 1x6 cell array where each element is a 22x1 cell or double array (the cell arrays contain text)
I want to expand the whole cell and then convert it to a table of the following format
X 1 Y 1 Z 1
X 2 Y 2 Z 2
X 3 Y 3 Z 3
X 4 Y 4 Z 4
.
.
.
.
X 22 Y 22 Z 22
I used cell2table and writecell but it doesn't help
Essentially I want to end up with a 22x6 table with letters on columns 1,3,5 and numbers on columns 2,4,6, and then and then convert the table to a txt file
Thank you.

採用された回答

Voss
Voss 2022 年 5 月 28 日
C = {{'X';'X';'X'} [1;2;3] {'Y';'Y';'Y'} [1;2;3] {'Z';'Z';'Z'} [1;2;3]} % your cell array
C = 1×6 cell array
{3×1 cell} {3×1 double} {3×1 cell} {3×1 double} {3×1 cell} {3×1 double}
T = table(C{:}) % make a table T
T = 3×6 table
Var1 Var2 Var3 Var4 Var5 Var6 _____ ____ _____ ____ _____ ____ {'X'} 1 {'Y'} 1 {'Z'} 1 {'X'} 2 {'Y'} 2 {'Z'} 2 {'X'} 3 {'Y'} 3 {'Z'} 3
writetable(T) % write the table to a text file
% check the file:
ls
T.txt
type T.txt
Var1,Var2,Var3,Var4,Var5,Var6 X,1,Y,1,Z,1 X,2,Y,2,Z,2 X,3,Y,3,Z,3
  2 件のコメント
Odysseas Makariou
Odysseas Makariou 2022 年 5 月 28 日
Thank you!
Voss
Voss 2022 年 5 月 28 日
You're welcome!

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by