Changing names and removing quotes in row2vars output table

7 次查看(过去 30 天)
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
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 个评论
KarolN
KarolN 2022-1-27
@dpb Thank you very much for solving my problem!
Just for your curiosity:
Parameters variable is neccessary, because it is the only way to have greek letters as table names.
fromSection was a name of a vector, which gathers the output from 9 equations. When I transposed the table MATLAB had to split it to preserve the logic of the output I guess
dpb
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 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by