Merge arrays into table and keep the variable names

조회 수: 27(최근 30일)
How can I merge arrays into a table and keep the variable names from the arrays=. I have tried to merge arrays into table like this:
In the new table the variable names is shown as var1,var2 and var3. I want the variable names to be shown as array1, array2 and array3. How can I do this?
  댓글 수: 2
Stephen23 2018년 3월 14일
Why not use struct2table then ?

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

채택된 답변

Birdman 2018년 3월 14일
table function has VariableNames option, which can be used as follows:
  댓글 수: 1
Peter Perkins
Peter Perkins 2018년 3월 15일
편집: Peter Perkins 2018년 3월 15일
You do not need this, though. In that code, the table's variable names will automatically be "array1", etc. So the original post is not telling us something important.
If the actual line of code were, for example
then you would have to specify variable names. But if it's really
then it happens automatically.
Edit: OK, also if the line is table(s.array1,s.array2,sarray3), then you would have to specify names. But as Stephen says, you should use struct2table for that.

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by