MATLAB: MatLab won’t allow me to label the columns in a table that I created

tablevariable names

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

Best Answer

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