How to reorder monthly row data into one column?

조회 수: 2 (최근 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 CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by