MatLab won't allow me to label the columns in a table that I created

16 vues (au cours des 30 derniers jours)
Hello,
I am trying to create a very simple table via the following code:
Latency_Info = [124, 203, 301; 143, 201, 280]
Latency_Table = table(Latency_Info)
Latency_Table.Row = ["T7", "T8"]
Latency_Table.Variables = ["P1", "N1", "P2"]
I am able to add the row names via this code, however, when I try to lable the coloumns of the table, I get the following error:
"To assign to, or create a variable in a table, the number of rows must match the height of the table."
Could anyone point me in the right direction to address this issue

Réponse acceptée

Star Strider
Star Strider le 10 Nov 2019
You are not creating your table correctly, and you are not using the correct syntax to set the row and column names.
Try this:
Latency_Info = [124, 203, 301; 143, 201, 280];
Latency_Table = array2table(Latency_Info);
Latency_Table.Properties.RowNames = ["T7", "T8"];
Latency_Table.Properties.VariableNames = ["P1", "N1", "P2"];
producing:
Latency_Table =
2×3 table
P1 N1 P2
___ ___ ___
T7 124 203 301
T8 143 201 280
  2 commentaires
Brittny Freeman
Brittny Freeman le 10 Nov 2019
This works perfectly,
Thank you so much Star!
Star Strider
Star Strider le 10 Nov 2019
As always, my pleasure!

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