How to get the order if one column has same number and other column has different values
조회 수: 1 (최근 30일)
이전 댓글 표시
I have the below cell table in MATLAB, I am using the "num2cell(transpose(Array_games( [true, diff(Array_games) ~= 0] )));" function to get the order of the first column, and I get the order as [0 1], but I want the order of the array_games as [0 0 1], because there is gap of 3 seconds inbetween array_games 0(row 4 and 5). Is there any way I can get that by using the column 2 with array_games column?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/980140/image.png)
댓글 수: 2
Dyuman Joshi
2022년 4월 27일
편집: Dyuman Joshi
2022년 4월 27일
So you are looking for positions/values from column 1 corresponding to column 2 with gaps >= 3 seconds?
답변 (2개)
Dyuman Joshi
2022년 4월 27일
Array_games = [0 0 0 0 0 0 0 1 1 1]';
Column_2 = [datetime(2022,2,25,19,06,57);datetime(2022,2,25,19,06,57);datetime(2022,2,25,19,06,58);...
datetime(2022,2,25,19,06,58);datetime(2022,2,25,19,07,01);datetime(2022,2,25,19,07,02);...
datetime(2022,2,25,19,07,02);datetime(2022,2,25,19,08,33);datetime(2022,2,25,19,08,33);...
datetime(2022,2,25,19,08,33)];
y=table(Array_games, Column_2)
%inital 1 to address for 1st element
[1 find(diff(y.Column_2)>=duration(0,0,3))'+1] %adding one to get the required index
y.Array_games([1 find(diff(y.Column_2)>=duration(0,0,3))'+1])
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!