If I have the following table in Matlab:
T = table(['KAT';'MAT';'PAT';'SAT';'RAT'],[38;43;38;40;49],[71;69;64;67;64],[176;163;131;133;119])
T =
5×4 table
Var1 Var2 Var3 Var4
____ ____ ____ ____
KAT 38 71 176
MAT 43 69 163
PAT 38 64 131
SAT 40 67 133
RAT 49 64 119
How do i refer to the entire row above PAT.
For example, the below code finds the row matching to PAT
>> T((ismember(T.Var1,'PAT','rows')),:)
ans =
1×4 table
Var1 Var2 Var3 Var4
____ ____ ____ ____
PAT 38 64 131
But when I deduct 1 in the index to find the row above the matched row for 'PAT' , i get the following error :
>> T((ismember(T.Var1,'PAT','rows')-1),:)
Index in position 1 is invalid. Array
indices must be positive integers or logical
values.
Is there any way i could find the row above to the row that matched for 'PAT' ??