How can I delete a specific row from a timetable?

12 visualizaciones (últimos 30 días)
Ashfaq Ahmed
Ashfaq Ahmed el 30 de En. de 2023
Comentada: Star Strider el 30 de En. de 2023
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.

Respuesta aceptada

Star Strider
Star Strider el 30 de En. de 2023
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 comentarios
Ashfaq Ahmed
Ashfaq Ahmed el 30 de En. de 2023
Wow! Wonderful! Thank you so much!
Star Strider
Star Strider el 30 de En. de 2023
As always, my pleasure!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre MATLAB en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by