How to reorder monthly row data into one column?

4 ビュー (過去 30 日間)
Elizabeth Lees
Elizabeth Lees 2020 年 11 月 17 日
コメント済み: Ameer Hamza 2020 年 11 月 17 日
I have a dataset in csv format which is formatted in yearly rows containing a value for each month (13 values total per row, first one being the year then followed by each month). I'd like to transpose this data into one long column of only the monthly values. I believe a loop might work but unsure how to apply it. Any help would be greatly apprciated.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 11 月 17 日
編集済み: Ameer Hamza 2020 年 11 月 17 日
Following assume variable M is n*13 matrix from csv file
M = readmatrix('filename.csv');
M_data = M(:,2:end); % exclude the years column
M_linear = reshape(M_data.', [], 1)
  2 件のコメント
Elizabeth Lees
Elizabeth Lees 2020 年 11 月 17 日
thank you so much! worked a treat
Ameer Hamza
Ameer Hamza 2020 年 11 月 17 日
I am glad to be of help! :)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by