Adding rows label to the table

16 vues (au cours des 30 derniers jours)
Rajeev Kumar
Rajeev Kumar le 3 Juil 2019
Commenté : Adam Danz le 3 Juil 2019
I am stuck in one implementation where I want to create a table with just column and row name. I am trying in the following way
Step1 : tab1 = cell2table(...) ; tab2=cell2table(...) ;tab3=cell2table(...)
Step2 : table = [tab1 tab2 tab3]
step3 : table..Properties.RowNames = x_name ; x_name is a cell array of specied element (say it is of size 1x20)
This is throwing the following error : The RowNames property must contain one name for each row in the table. Can I create a table with only rows and column name
  2 commentaires
Guillaume
Guillaume le 3 Juil 2019
I don't know what you mean by only rows and columns name.
In theory your code would work, as long as the table you created has indeed 20 rows. If not, as the error message says the number of elements of x_name must match the number of rows. You can't have unnamed rows.
So, most likely the problem is with the code you don't show.
Note that you should only call cell2table once. You can concatenate the cell arrays beforehand. That would be more efficicent than concatenating tables.
Adam Danz
Adam Danz le 3 Juil 2019
Just as the error indicates, the number of row names needs to equal the number of rows os your table. numel(rownames) == size(table,1).
Also, assuming your cell arrays all have the same number of rows, you could probably build your table more easily like this
table = cell2table([c1, c2, c3])

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Tables dans Help Center et File Exchange

Tags

Produits


Version

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by