How can I delete a specific row from a timetable?

21 ビュー (過去 30 日間)
Ashfaq Ahmed
Ashfaq Ahmed 2023 年 1 月 30 日
コメント済み: Star Strider 2023 年 1 月 30 日
Hi!
Thank you for all the supports you guys always provide here. I have a question. I attached a timetable. It's a very simple timetable.mat file with only 15 rows.
What I want is to delete those rows that has the beginning hours, for example, 01:00, 04:00, 06:00, 08:00 etc. And I want to keep the only time rows that are in between, such as, 03:15, 08:12, 11:39.
Can anyone please help me with this issue? The .mat file is attached with the question.

採用された回答

Star Strider
Star Strider 2023 年 1 月 30 日
Try something like this —
LD = load(websave('TimeTable','https://www.mathworks.com/matlabcentral/answers/uploaded_files/1278715/TimeTable.mat'));
Period = LD.Period
Period = 15×2 timetable
TimeSeries HourSeries HeightSeries ___________ __________ ____________ 01-Jan-2004 {'00:00'} 0.207 01-Jan-2004 {'01:00'} 0.189 01-Jan-2004 {'01:12'} 0.226 01-Jan-2004 {'02:00'} 0.263 01-Jan-2004 {'03:15'} 0.318 01-Jan-2004 {'04:00'} 0.394 01-Jan-2004 {'07:08'} 0.58 01-Jan-2004 {'06:00'} 0.843 01-Jan-2004 {'07:00'} 1.065 01-Jan-2004 {'08:00'} 1.149 01-Jan-2004 {'08:12'} 1.1155 01-Jan-2004 {'09:00'} 1.082 01-Jan-2004 {'10:00'} 0.918 01-Jan-2004 {'11:39'} 0.693 01-Jan-2004 {'12:00'} 0.458
Period.TimeSeries = Period.TimeSeries + timeofday(datetime(Period.HourSeries, 'InputFormat','HH:mm'))
Period = 15×2 timetable
TimeSeries HourSeries HeightSeries ____________________ __________ ____________ 01-Jan-2004 00:00:00 {'00:00'} 0.207 01-Jan-2004 01:00:00 {'01:00'} 0.189 01-Jan-2004 01:12:00 {'01:12'} 0.226 01-Jan-2004 02:00:00 {'02:00'} 0.263 01-Jan-2004 03:15:00 {'03:15'} 0.318 01-Jan-2004 04:00:00 {'04:00'} 0.394 01-Jan-2004 07:08:00 {'07:08'} 0.58 01-Jan-2004 06:00:00 {'06:00'} 0.843 01-Jan-2004 07:00:00 {'07:00'} 1.065 01-Jan-2004 08:00:00 {'08:00'} 1.149 01-Jan-2004 08:12:00 {'08:12'} 1.1155 01-Jan-2004 09:00:00 {'09:00'} 1.082 01-Jan-2004 10:00:00 {'10:00'} 0.918 01-Jan-2004 11:39:00 {'11:39'} 0.693 01-Jan-2004 12:00:00 {'12:00'} 0.458
RowsToKeep = minute(Period.TimeSeries) ~= 0
RowsToKeep = 15×1 logical array
0 0 1 0 1 0 1 0 0 0 1 0 0 1 0
PeriodEdited = Period(RowsToKeep,:)
PeriodEdited = 5×2 timetable
TimeSeries HourSeries HeightSeries ____________________ __________ ____________ 01-Jan-2004 01:12:00 {'01:12'} 0.226 01-Jan-2004 03:15:00 {'03:15'} 0.318 01-Jan-2004 07:08:00 {'07:08'} 0.58 01-Jan-2004 08:12:00 {'08:12'} 1.1155 01-Jan-2004 11:39:00 {'11:39'} 0.693
.
  2 件のコメント
Ashfaq Ahmed
Ashfaq Ahmed 2023 年 1 月 30 日
Wow! Wonderful! Thank you so much!
Star Strider
Star Strider 2023 年 1 月 30 日
As always, my pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTables についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by