create table from matrix and cell variables

9 ビュー (過去 30 日間)
Ildiko Magda
Ildiko Magda 2019 年 7 月 13 日
コメント済み: Ildiko Magda 2019 年 7 月 13 日
I would like to create a table using multiple variables, but can't figure out how to. my output table should look like a 21 x 176 table.
I have 4 variables
A = 18 x257 x 176 double
B = 176 x1 cell
C= 176 x 1 cell
D = 176 x 1 cell
I would like a table with 21 rows and 176 columns, but I can't figure out how. The rows would be A(1), B, C, and D
Thank you for any help ,
  1 件のコメント
madhan ravi
madhan ravi 2019 年 7 月 13 日
upload data file

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

採用された回答

the cyclist
the cyclist 2019 年 7 月 13 日
編集済み: the cyclist 2019 年 7 月 13 日
I'm not certain what you want, but I think this is it.
% Make up some original inputs
A = rand(18,257,176);
B = cell(176,1);
C = cell(176,1);
D = cell(176,1);
% Pull out the slice of A for the table
As = A(:,1,:);
% Transform each variable to the correct shape for the table, and also
% convert A to cell for convenience
Ar = reshape(As,[18,176]);
At = num2cell(Ar);
Bt = B.';
Ct = C.';
Dt = D.';
% Concatenate to one cell array
wholeCell = [At; Bt; Ct; Dt];
% Convert the cell array to a table
tbl = cell2table(wholeCell);
Many of these steps could be combined, for shorter code, but I thought it would be to be clearer about what each step is doing.
  1 件のコメント
Ildiko Magda
Ildiko Magda 2019 年 7 月 13 日
Absolutely amazing, thank you. And thank you for the detailed steps, I'm learning, so it's very useful to me to understand

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by