How can I convert tables to array, given that these tables contain variables with similar variable names?

조회 수: 2 (최근 30일)
I have tables that contain variables (columns) with the same names across all variables in these tables: VarName1, VarName2, ... VarName(N)
When I try to add these tables to a single array table (using "table2array" or "horzcat") I get this error message: "Duplicate variable name: 'VarName1' ".
How can I use this function to combine these tables into a single array without having to change all the variable names?
I couldn't find a clear answer.
  댓글 수: 2
Guillaume
Guillaume 2018년 12월 6일
편집: Guillaume 2018년 12월 6일
More important than the tables is a better description of the steps that lead to the error and the exact error. Also, a better explanation of what you're trying to do.
table2array does not care one bit about the variable names since it gets rid of that information. It is never going to raise the error message "Duplicate variable name: 'VarName1' ".

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

답변 (1개)

jonas
jonas 2018년 12월 6일
It is unclear if you want to output an array or a table, but the nature of the error message suggests that you're trying to combine multiple tables into one, in which case you can use:
array2table([T1.Variables,T2.Variables])
This relabels the column names to avoid duplicates.

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by