MATLAB Answers

table less than operator

46 views (last 30 days)
sani
sani on 17 Jan 2020 at 19:27
Commented: sani on 18 Jan 2020 at 8:30
hi,
I'm having this error : Undefined operator '<' for input arguments of type 'table'.
how can I write the operator less than for table?
I ttied using gt(A,B) and lt(A,B) but it still give me this error.
I still want to use table and not to convert the table to array.
thanks!

  2 Comments

Walter Roberson
Walter Roberson on 17 Jan 2020 at 19:45
What does it mean to you for a table to be less than something? Are you sure you do not instead want to compare the content of a variable in the table to something?
sani
sani on 17 Jan 2020 at 19:57
Hi,
yes this what I'm trying to do

Sign in to comment.

Answers (1)

Matt J
Matt J on 17 Jan 2020 at 21:10
Are you sure you do not instead want to compare the content of a variable in the table to something?... yes this what I'm trying to do.
Then why are you trying to apply < or > to the entire table? You should be applying it to a specific variable, like in the following example:
T =
5×6 table
LastName Age Smoker Height Weight BloodPressure
_________ ___ ______ ______ ______ _____________
'Sanchez' 38 true 71 176 124 93
'Johnson' 43 false 69 163 109 77
'Li' 38 true 64 131 125 83
'Diaz' 40 false 67 133 117 75
'Brown' 49 true 64 119 122 80
>> T.Age<=40
ans =
5×1 logical array
1
0
1
1
0

  7 Comments

Show 4 older comments
sani
sani on 17 Jan 2020 at 23:05
So in my case time variable in in the 1st column of the table, is it becaus this syntex call a sub-table and not for a variable it didn't worked?
Walter Roberson
Walter Roberson on 18 Jan 2020 at 0:40
Change
prev = T1(i,1);
to
prev = T1{i,1};
sani
sani on 18 Jan 2020 at 8:30
Thanks!

Sign in to comment.

Sign in to answer this question.