Rearrange rows in a table

34 ビュー (過去 30 日間)
daniele marchese
daniele marchese 2021 年 12 月 21 日
編集済み: Walter Roberson 2021 年 12 月 21 日
Hello to everyone,
I have a 48x5 table.
my goal is to horizontally concatenate each rows as successive columns in order to reach a 1x240 finale table.
1 60 25 98, 1 60 25 98,1 60 25 98, 1 60 25 98, 1 60 25 98, 1 60 35 98, 1 60 35 98, 1 60 35 98, 1 60 35 98 ...
i guess it is a simple task but cant find a simple solution
thank you very much for any help

回答 (1 件)

Walter Roberson
Walter Roberson 2021 年 12 月 21 日
tempTable = splitvars(YourTable);
data_as_single_row = reshape(tempTable{:,:}.', 1, []);
You can put data_as_single_row into a table, but the question then becomes what column names you want for each entry.
  2 件のコメント
daniele marchese
daniele marchese 2021 年 12 月 21 日
first of all, thank you very much for your fast reply.
the thing is i need to assign each variable within the previous 1x240 table to a 8x240 matrix in that order:
1 60 25 98, 1 60 25 98,1 60 25 98, 1 60 25 98, 1 60 25 98, 1 60 35 98, 1 60 35 98, 1 60 35 98, 1 60 35 98 ...
Walter Roberson
Walter Roberson 2021 年 12 月 21 日
編集済み: Walter Roberson 2021 年 12 月 21 日
num_rows = numel(Cell_Of_Tables);
output = zeros(num_rows, 240);
for K = 1 : num_rows
tempTable = splitvars(Cell_Of_Tables{K});
data_as_single_row = reshape(tempTable{:,:}.', 1, []);
output(K,:) = data_as_single_row;
end
where Cell_Of_Tables is a cell array, each entry of which is a table() object.

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

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by