I have a table with 5 columns which represent different variables
T = cell2table(MyArray,'VariableNames',{'ID' 'Region' 'Int_Den' 'Area' 'Group'});
Then, I used unstack to kind of reorganize it
S = unstack(T,'Int_Den','ID');
However, this is not exactly what I need. You can see from the screenshot below that I have a 294x52 table, where the majority of values are NaN. Instead of this, I would like to have a table where the first column is the "Region", and then the IDs will be distributed from columns 2 to 50. At the end the table should be 6 rows x 50 columns.
Thanks,

댓글 수: 1

Cris LaPierre
Cris LaPierre 2020년 9월 30일
I think we need more more information about your table to help. Any chance you can attach a mat file containing T or MyArray?

댓글을 달려면 로그인하십시오.

 채택된 답변

Mohammad Sami
Mohammad Sami 2020년 9월 30일

3 개 추천

The remaining variables are used by unstack as grouping variables. You should exclude them when calling unstack.
T = cell2table(MyArray,'VariableNames',{'ID' 'Region' 'Int_Den' 'Area' 'Group'});
S = unstack(T(:,{'ID' 'Region' 'Int_Den'}),'Int_Den','ID');

댓글 수: 3

Star Strider
Star Strider 2020년 9월 30일
Mohammad Sami — I would like to vote for your Answer, however there is some sort of problem with the page, and I cannot.
+1 in spirit if not in fact
Mohammad Sami
Mohammad Sami 2020년 10월 1일
Thanks :)
Star Strider
Star Strider 2020년 10월 1일
Apparently, that got fixed!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

질문:

2020년 9월 29일

댓글:

2020년 10월 1일

Community Treasure Hunt

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

Start Hunting!

Translated by