Conditional find in matlab
1 view (last 30 days)
Show older comments
Amir Mahmoudi
on 18 Jan 2024
Commented: Les Beckham
on 18 Jan 2024
I = find(X == a,1,'first'), J = find(X == b,1,'first'), K = find(X == c,1,'first') provided that K > J > I How can I implement the conditional part? Thanks in advance.
0 Comments
Accepted Answer
Les Beckham
on 18 Jan 2024
Edited: Les Beckham
on 18 Jan 2024
X = [10 20 30 40 50 10 20 30 40 50];
a = 30;
b = 20;
I = find(X == a, 1, 'first')
J = find(X((I+1):end) == b, 1, 'first') + I % start search after index I
X(I)
X(J)
2 Comments
More Answers (0)
See Also
Categories
Find more on Whos in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!