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

10 次查看(过去 30 天)
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

采纳的回答

Star Strider
Star Strider 2019-11-10
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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Tables 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by