How can I find the continous time between two points( ex 1,2,3,4,5,6,7,8,9,10 in between 1 and 10)

2 次查看(过去 30 天)
I included the image, but how can I find the time inbtween T1 and T2. I want to find all time points between t1 and t2, like 20390, 20391,20392.... 20400, and 22578,22579,.....22588 and so on for every row
  2 个评论
dpb
dpb 2022-10-17
t=(t1:t2).';
will return all values between t1, t2 inclusive separated by 1.
See colon, : for more detail, using different increments, etc., ...
linspace could also be of interest or if you would turn your data into a duration, then a timetable could be useful and a whole new universe opens up.

请先登录,再进行评论。

回答(1 个)

Voss
Voss 2022-10-17
Here's your table:
DeltaShortTable = table( ...
[20390; 22578; 25894; 29041; 31924; 34937; 37982; 41045; 44022; 46905; 49676; 52264; 54934; 57565; 60374; 63475; 66871; 70152], ...
[20400; 22588; 25904; 29051; 31934; 34947; 37992; 41055; 44032; 46915; 49686; 52274; 54944; 57575; 60384; 63485; 66881; 70162], ...
'VariableNames',{'TEMPtensecpulsecT1' 'TEMPtensecpulsecT2'})
DeltaShortTable = 18×2 table
TEMPtensecpulsecT1 TEMPtensecpulsecT2 __________________ __________________ 20390 20400 22578 22588 25894 25904 29041 29051 31924 31934 34937 34947 37982 37992 41045 41055 44022 44032 46905 46915 49676 49686 52264 52274 54934 54944 57565 57575 60374 60384 63475 63485
Here's one way to do what you want:
result = arrayfun(@(s,e)s:e, ...
DeltaShortTable.TEMPtensecpulsecT1,DeltaShortTable.TEMPtensecpulsecT2, ...
'UniformOutput',false)
result = 18×1 cell array
{[20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400]} {[22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588]} {[25894 25895 25896 25897 25898 25899 25900 25901 25902 25903 25904]} {[29041 29042 29043 29044 29045 29046 29047 29048 29049 29050 29051]} {[31924 31925 31926 31927 31928 31929 31930 31931 31932 31933 31934]} {[34937 34938 34939 34940 34941 34942 34943 34944 34945 34946 34947]} {[37982 37983 37984 37985 37986 37987 37988 37989 37990 37991 37992]} {[41045 41046 41047 41048 41049 41050 41051 41052 41053 41054 41055]} {[44022 44023 44024 44025 44026 44027 44028 44029 44030 44031 44032]} {[46905 46906 46907 46908 46909 46910 46911 46912 46913 46914 46915]} {[49676 49677 49678 49679 49680 49681 49682 49683 49684 49685 49686]} {[52264 52265 52266 52267 52268 52269 52270 52271 52272 52273 52274]} {[54934 54935 54936 54937 54938 54939 54940 54941 54942 54943 54944]} {[57565 57566 57567 57568 57569 57570 57571 57572 57573 57574 57575]} {[60374 60375 60376 60377 60378 60379 60380 60381 60382 60383 60384]} {[63475 63476 63477 63478 63479 63480 63481 63482 63483 63484 63485]}
If each pair of numbers always have the same difference (which they do in this case, that being 10), then you can do this:
result = vertcat(result{:})
result = 18×11
20390 20391 20392 20393 20394 20395 20396 20397 20398 20399 20400 22578 22579 22580 22581 22582 22583 22584 22585 22586 22587 22588 25894 25895 25896 25897 25898 25899 25900 25901 25902 25903 25904 29041 29042 29043 29044 29045 29046 29047 29048 29049 29050 29051 31924 31925 31926 31927 31928 31929 31930 31931 31932 31933 31934 34937 34938 34939 34940 34941 34942 34943 34944 34945 34946 34947 37982 37983 37984 37985 37986 37987 37988 37989 37990 37991 37992 41045 41046 41047 41048 41049 41050 41051 41052 41053 41054 41055 44022 44023 44024 44025 44026 44027 44028 44029 44030 44031 44032 46905 46906 46907 46908 46909 46910 46911 46912 46913 46914 46915
  3 个评论
Youssif Youssif
Youssif Youssif 2022-10-17
This worked, thanks, but for addition, do you know how to make it so its (18*18) x 1, where all data is in one row and in assecnding order

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrices and Arrays 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by