MATLAB Answers

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).

22 views (last 30 days)
Lihi Cohen
Lihi Cohen on 21 Jul 2021
Answered: Peter Perkins on 27 Jul 2021
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.

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

Tags

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by