Newbie
Newbie

Reputation: 23

Extracting all rows containing a specific datetime value (MATLAB)

I have a table which looks like this:

Entry number Timestamp Value1 Value2 Value3 Value4
5758 28-06-2018 16:30 34 63 34.2 60.9
5759 28-06-2018 17:00 33.5 58 34.9 58.4
5758 28-06-2018 16:30 34 63 34.2 60.9
5759 28-06-2018 17:00 33.5 58 34.9 58.4
5760 28-06-2018 17:30 33 53 35.2 58.5
5761 28-06-2018 18:00 33 63 35 57.9
5762 28-06-2018 18:30 33 61 34.6 58.9
5763 28-06-2018 19:00 33 59 34.1 59.4
5764 28-06-2018 19:30 28 89 33.5 64.2
5765 28-06-2018 20:00 28 89 33 66.1
5766 28-06-2018 20:30 28 83 32.5 67
5767 28-06-2018 21:00 29 89 32.2 68.4

Where '28-06-2018 16:30' is under one column. So I have 6 columns:

Entry number, Timestamp, Value1, Value2, Value3, Value4

I want to extract all rows that belong to '28-06-2018', i.e all data pertaining to that day. Since my table is too large I couldn't fit more data, however, the entries under the timestamp range for a couple of months.

Upvotes: 1

Views: 124

Answers (1)

X Zhang
X Zhang

Reputation: 1325

t=table([5758;5759],["28-06-2018 16:30";"29-06-2018 16:30"],[34;33.5],'VariableNames',{'Entry number','Timestamp','Value1'})

t =

2×3 table

Entry number        Timestamp         Value1
____________    __________________    ______

    5758        "28-06-2018 16:30"       34 
    5759        "29-06-2018 16:30"     33.5
t(contains(t.('Timestamp'),"28-06"),:)

ans =

1×3 table

Entry number        Timestamp         Value1
____________    __________________    ______

    5758        "28-06-2018 16:30"      34

Upvotes: 1

Related Questions