Effacer les filtres
Effacer les filtres

How to have same heading for different columns in the table?

15 vues (au cours des 30 derniers jours)
Ananta Bijoy
Ananta Bijoy le 23 Oct 2023
I have the following table attached. In this table, I need 1st, 4th, 7th colum heading 'Time'. The 3rd and 6th colum heading should be 'NaN'. i tried the renamevars command but same name can not appear in tow different colum heading. How can I solve that problem.
  2 commentaires
Voss
Voss le 23 Oct 2023
Column names in a table must be distinct, so you're not going to be able to have multiple columns called 'Time', for instance.
Siddharth Bhutiya
Siddharth Bhutiya le 1 Nov 2023
As others have mentioned table variable names need to be unique. But let's say that was allowed then what are you trying to do after renaming the variables? Looking at the data it seems that you have 3 different tables and you are sort of using the NaN variables as a "separator". If all this is just for display purposes then you can try some of the workarounds suggested in other answers but if there is some workflow that follows the renaming process then describing that might lead to other useful answers.

Connectez-vous pour commenter.

Réponses (2)

Star Strider
Star Strider le 23 Oct 2023
I would just name the ‘Time’ variables as ‘Time1’, ‘Time2’ and ‘Time3’ to match the ‘v’ columns. The NaN columns are likely not necessary.
.

the cyclist
the cyclist le 23 Oct 2023
Modifié(e) : the cyclist le 23 Oct 2023
You can't have identical column names. If it's just for display purposes, you could add whitespace.
t1 = rand(3,1);
t2 = rand(3,1);
tbl = table(t1,t2,'VariableNames',["time","time "])
tbl = 3×2 table
time time _______ _______ 0.77625 0.866 0.72336 0.8574 0.795 0.48366
This seems like a terrible idea for actually using the table for any purpose.
I'm curious what your use case is.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by