Subscripting into a table using three or more subscripts (as in t(i,j,k)) is not supported. Always specify a row subscript and a variable subscript, as in t(rows,vars).

130 views (last 30 days)
Hi,
I am trying to create a joined table from 4 arrays (each has the same amount of elements), whay does this error means?
this is part of my code:
%turn table to int array
baseline = table2array(baseline);
retest1 = table2array(retest1);
retest2 = table2array(retest2);
retest3 = table2array(retest3);
%create a table for plotting
correct_sequences_table = table(baseline, retest1, retest2, retest3)
Error: Subscripting into a table using three or more subscripts (as in
t(i,j,k)) is not supported. Always specify a row subscript and a
variable subscript, as in t(rows,vars).

Answers (2)

Walter Roberson
Walter Roberson on 21 Jul 2021
You accidentally created a variable named table that is a member of the object class named table . In the line that is having the problem, MATLAB thinks that you are trying to index the variable named table instead of trying to create a new table object.
  3 Comments
Walter Roberson
Walter Roberson on 4 May 2022
T = table;
clear table
Now the old value is in T and you can use table() as a function again.
Note that generally speaking the error about wrong number of subscripts indexing a table is often a slightly different problem than here. This analysis only holds for lines where it is complaining with that error on a line that appears to be creating a table. In cases where a different variable name appears, the problem is often trying to use just a row number to index a table, such as
T(5)
when you would need
T(5,:)
or a column reference as the second parameter, such as
T(5,'power_level')
T{5,3}

Sign in to comment.


Peter Perkins
Peter Perkins on 27 Jul 2021
Lihi, hard to say for sure, but you may want to make a table that contains those four tables. For example:
>> baseline = table([1;2;3],[4;5;6],'VariableNames',["X" "Y"])
baseline =
3×2 table
X Y
_ _
1 4
2 5
3 6
>> retest1 = table([7;8;9],[10;11;12],'VariableNames',["W" "Z"])
retest1 =
3×2 table
W Z
_ __
7 10
8 11
9 12
>> t = table(baseline,retest1)
t =
3×2 table
baseline retest1
X Y W Z
________ _______
1 4 7 10
2 5 8 11
3 6 9 12
>> t.baseline.X
ans =
1
2
3

Categories

Find more on Tables in Help Center and File Exchange

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!