How to get data every second from table that has variable sampling time

hello, i have problem to extract data from a table. My data table :
time = [ 0 0.0010 0.0021 0.0031 0.0041 0.0053 and so on........ ]
torque = [ 0 1.22 1.32 1.32 1.42 1.60 and so on..........]
my problem is, how to extract data every 0.001 second while my data table have sampling time between 0.001 and 0.002.
If I have fixed sampling time, then i can extract data at interval and that would be easy.
I have 162000 data so i can't sort every single cell to get data at exactly 0.001 second interval.
Any help would be appreciate thank you.....

 채택된 답변

Walter Roberson
Walter Roberson 2019년 4월 23일

0 개 추천

Create a timetable() object and use retime()

댓글 수: 4

time = [ 0 0.0010 0.0021 0.0031 0.0041 0.0053];
torque = [ 0 1.22 1.32 1.32 1.42 1.60];
TT = timetable(seconds(time(:)),torque(:));
TT_out = retime(TT,seconds(0:.001:.005)','linear');
TT_out = retime(TT, 'Regular', 'TimeStep', 0.001);
Yes Walter! But I use R2016b. :)
Thank you guys it works with no problem

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

추가 답변 (1개)

KSSV
KSSV 2019년 4월 23일
Read about interp1.
time = [ 0 0.0010 0.0021 0.0031 0.0041 0.0053 ] ;
torque = [ 0 1.22 1.32 1.32 1.42 1.60] ;
dt = 0.001 ;
ti = min(time):dt:max(time) ;
iwant = interp1(time,torque,ti)

카테고리

도움말 센터 및 File Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by