Adding a variable to a table

2 vues (au cours des 30 derniers jours)
Newbie
Newbie le 23 Nov 2020
Commenté : Newbie le 30 Nov 2020
Suppose I have a table with row names but no variable names. I want to make the first row in my table (attached) to be recognized as the variables in my table and be able to have variables as my x axe in a plot when ploting the rows as a time series.

Réponse acceptée

Nagasai Bharat
Nagasai Bharat le 27 Nov 2020
Hi,
From my understanding you are trying make your first row as the variables of your table Tx. The following script would help you achieve it.
load Tx
VarNames = string(cell2mat(table2cell(Tx(1,:))));
Tx(1,:) = [];
Tx.Properties.VariableNames = VarNames;
  1 commentaire
Newbie
Newbie le 30 Nov 2020
Hi Nagasai,
I ran the script and got the following message:
'300' is not a valid table variable name. See the documentation for isvarname or matlab.lang.makeValidName for more information.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by