I have a time table created as follows
TT_T=timetable(T_T,a_X_T,a_Y_T,a_Z_T,w_X_T,w_Y_T,w_Z_T,Mag_X_T,Mag_Y_T,Mag_Z_T,Pres_P_T,Press_T_T,P_V_T);
T_T is a datetime column with this format
'10:49:26.724'
'10:49:26.726'
'10:49:26.729'
'10:49:26.731'
... it continues for 1 hour
I tried to select rows with "timerange"
A=timerange('10:53:32','10:53:38')
impact=TT_T(A,:);
But it shows me this error:
"A timetable with datetime row times cannot be subscripted using duration values."

 Respuesta aceptada

Star Strider
Star Strider el 6 de Sept. de 2021
One option is to convert ‘T_T’ to a duration array, so timerange would work with it.
Another option is to use logical indexing —
tr = [datetime('10:53:32') datetime('10:53:38')] % Time Limits
Lv = (TT_T.T_T >= tr(1)) & (TT_T.T_T <] tr(2)); % Logical Vector
A = TT_T(Lv,:)
These could be combined into fewer lines. I separated them so that it would be more obvious.
I cannot test this, so I am posting it as UNTESTED CODE. I have used a similar approach in other situations, so I am reasonably confident that it will work, however it may need a few tweaks.
.

Más respuestas (0)

Categorías

Preguntada:

el 6 de Sept. de 2021

Respondida:

el 6 de Sept. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by