how to continuously loop until a condition is met?

13 views (last 30 days)
rafe brooks
rafe brooks on 5 Jan 2021
Commented: jessupj on 6 Jan 2021
I have a set of data that is varying throughout (force plate data) . I am trying to find the bodyweight of the particpants as it loops through the whole script. I tried to use the mode(A) function and it worked for most but not all as the data varies between them all. So, how can i write a loop that keeps using the mode function until it finds a value that is above 400 and below 1000?
  1 Comment
jessupj
jessupj on 5 Jan 2021
see the idea of a 'while' loop. you'd want something like:
value = InF;
while ~(value>400 && value<1000 );
% perform operations
value = ??? % some updated value based on the operations at this stage
end

Sign in to comment.

Answers (1)

madhan ravi
madhan ravi on 5 Jan 2021
Edited: madhan ravi on 5 Jan 2021
value = % calculate mode;
while 1
if ((value <= 4e2) && (value <= 1e3))
break
else
% value = calculate mode again , if it doesn't satisfy
end
end
  6 Comments
jessupj
jessupj on 6 Jan 2021
i agree completely that there are instances where this would be the natural way to do it. however, i did not (and still don't... ) see anything in the OP question that indicates it is 'more natural' here.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!