Finding a value based on multiple conditions of the next row

1 Ansicht (letzte 30 Tage)
Jorge Young
Jorge Young am 14 Sep. 2020
Kommentiert: Jorge Young am 14 Sep. 2020
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.

Akzeptierte Antwort

KSSV
KSSV am 14 Sep. 2020
idx = find(DrivenTime(Procedure==2)) ;
PReviousRow = idx(1)-1
  3 Kommentare
KSSV
KSSV am 14 Sep. 2020
[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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by