MATLAB Answers

Find a value when it meets two conditions

1 view (last 30 days)
Saad Alqahtani
Saad Alqahtani on 27 Jun 2021
Commented: Saad Alqahtani on 1 Jul 2021
Hi,
I'm trying to find a specific value in an array when it meets two conditions (1- as soon as it occur the first time, 2- if its longer than 2 seconds), then, I want the code to stop and give me the length from the beginng to that value that mets both conditions. Here is my code:
t= (2*2048);
for i = 1:length (M)
if W = find ((M >=5) & i > t)
break
W = length(i);
end
end
Thanks in advance for the help.
  4 Comments
Saad Alqahtani
Saad Alqahtani on 1 Jul 2021
Thanks. That helps, although I might need to modify it a bit.

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!

Translated by