Filter löschen
Filter löschen

Expanding a cell array in table into multiple rows

17 Ansichten (letzte 30 Tage)
AT_HYZ
AT_HYZ am 6 Mär. 2024
Bearbeitet: Matt J am 6 Mär. 2024
Hi, I have a table like this
I would like to have something like this but for Column A and B, I would like to split into 1500 x 1 double for 123 rows and for B, the same 1500x1 double should be printed into 123 rows. It's something like below but I don't know how to work for column A and B. Column A is basically becoming a column vector (1500 x 1 double) from a matrix (1500x123).
Could anyone help? thank you.
  1 Kommentar
Dyuman Joshi
Dyuman Joshi am 6 Mär. 2024
Please save the table as a .mat file and share it here. Use the paperclip button to upload.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Matt J
Matt J am 6 Mär. 2024
Bearbeitet: Matt J am 6 Mär. 2024
Here's a scaled-down example:
T=table(1,2,3,{rand(4,3)}, {rand(4,1)});
T.Properties.VariableNames(end-1:end)=["A","B"]
T = 1×5 table
Var1 Var2 Var3 A B ____ ____ ____ ____________ ____________ 1 2 3 {4×3 double} {4×1 double}
n=width(T{1,"A"}{1});
T=repmat(T,n,1);
T.A=reshape( num2cell(T{:,"A"}{1},1), [],1)
T = 3×5 table
Var1 Var2 Var3 A B ____ ____ ____ ____________ ____________ 1 2 3 {4×1 double} {4×1 double} 1 2 3 {4×1 double} {4×1 double} 1 2 3 {4×1 double} {4×1 double}

Weitere Antworten (0)

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by