Changing names and removing quotes in row2vars output table

조회 수: 9(최근 30일)
KarolN 2022년 1월 25일
댓글: dpb 2022년 1월 27일
I have generated an output table with iteration data from several equations:
I transposed the table for greater viewing comfort with splitvars and row2vars:
But now, I have some new row and column names, plus those ugly quote marks.
Now: how to replace Var1, Var2, Var3 etc with 'h', 'A', 'P', 'R', 'Energy E' etc.?
How to get rid of that 'Original/VariableNames' in top left corner?
And how to remove quotations from data?

채택된 답변

dpb 2022년 1월 25일
As always, if you would show the code you used to create the table, it would make our job much easier...
The table command and friends (like array2table) have the named input parameter 'VariableNames' that you can use to create the names you wish on creation, or you can use the tableName.Properties.VariableNames property to assign the names after creation.
However, from the content of the table, it appears you did not use the "ReadVariableNames,1" parameter in order for whichever of the functions you did use that would have read the first record as variable names and given you those automagically.
Doing that would then let all the other data be treated as numeric and then being numbers, the apostrophes will go away.
The apostrophes are a display feature of MATLAB command window and cannot be removed from fields that are strings; they are the visual clue as to what type of variable is in the given column; a cellstr and char string variable are also shown as either in curly braces or single quotes. But, if you do the above and fix it to read the first record as variable names, then they will be seen as numeric and all will be well in the world.
  댓글 수: 4
dpb 2022년 1월 27일
"... because it is the only way to have greek letters as table names."
Yech! Another terrible thing to have to then enter in order to use the data alll for a little visual bling.

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

추가 답변(0개)

Community Treasure Hunt

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

Start Hunting!

Translated by