how to extract the data for specific interval?

조회 수: 14 (최근 30일)
AS
AS 2021년 11월 12일
댓글: Star Strider 2021년 11월 15일
I have a datasets of time and value with time interval 0.1 sec. But, I want to extract the value and corresponding time for 0.5 sec from that. Please provide me any suggestion. Thanks.

채택된 답변

Star Strider
Star Strider 2021년 11월 12일
I am not exactly certain what the desired result is, however the retime funciton will likely produce it, regardless.
Assuming that is to re-sample the table from 0.1 second resolution to 0.5 second resolution,
T1 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/797754/Book2.xlsx', 'VariableNamingRule','preserve')
T1 = 11×2 table
time data2 ______ _______ 9334 0.48445 9334.1 0.48506 9334.2 0.48386 9334.3 0.48294 9334.4 0.48416 9334.5 0.48688 9334.6 0.48765 9334.7 0.49532 9334.8 0.5 9334.9 0.50005 9335 0.5001
T1.time = seconds(T1.time); % Convert 'time' From Numeric To A 'duration' Array
TT1 = table2timetable(T1)
TT1 = 11×1 timetable
time data2 __________ _______ 9334 sec 0.48445 9334.1 sec 0.48506 9334.2 sec 0.48386 9334.3 sec 0.48294 9334.4 sec 0.48416 9334.5 sec 0.48688 9334.6 sec 0.48765 9334.7 sec 0.49532 9334.8 sec 0.5 9334.9 sec 0.50005 9335 sec 0.5001
TT1 = retime(TT1, 'regular','linear', 'Timestep',seconds(0.5))
TT1 = 3×1 timetable
time data2 __________ _______ 9334 sec 0.48445 9334.5 sec 0.48688 9335 sec 0.5001
The interpolation method is required in the event that there are missing times. It does not affect values that already exist at the chosen times.
.
  댓글 수: 2
AS
AS 2021년 11월 15일
Thank you.
Star Strider
Star Strider 2021년 11월 15일
As always, my pleasure!
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by