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.
Youssif Youssif
Youssif Youssif 2022년 10월 17일
this worked only for the first row, any ideas to make it for all the rows?

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

답변 (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