Finding a value based on multiple conditions of the next row

조회 수: 1 (최근 30일)
Jorge Young
Jorge Young 2020년 9월 14일
댓글: Jorge Young 2020년 9월 14일
I need to find the row in a csv that comes right before a row where multiple conditions are met for example, the .csv look something like:
I basically need the DisttoStartPoint at of Procedure 1 when Procedure 2 has a DriveTime of <1
I can get the DistToStartPoint of the Procedure 2 by using condtions but I can not figure out how to get the info from the previous row.
Thank you.

채택된 답변

KSSV
KSSV 2020년 9월 14일
idx = find(DrivenTime(Procedure==2)) ;
PReviousRow = idx(1)-1
  댓글 수: 3
KSSV
KSSV 2020년 9월 14일
[c,ia,ib] = unique(Procedure) ;
for i = 2:length(c)
idx = find(DrivenTime(Procedure==c(i))<1) ;
if ~isempty(idx)
PreviousRow = idx(1)-1 ;
end
end

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

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by