MATLAB: How to run a function again and again till a condition satisfies Hello, i have a function which i want to run again and again till the condition is fulfilled. please please help me…. Best Answer suchismita, see e.g., flag = false; cnt = 0; while ~flag cnt = cnt + 1; fprintf('Try no.: %d\n', cnt); if (rand() < 0.25) flag = true; end endYour function would simply reside inside the loop. Related SolutionsMATLAB: How to write Conditional for loop in matlab without giving range? and it should run till condition satisfied You should use while loop instead. Here is the link: whileHere is a sample code for your case: K=0;Flag = 1;while Flag == 1 if K > 4 Flag = 0 else K = K+1 Flag = 1 endend MATLAB: How to ensure that a triggered subsystem is run after the supersystem in Simulink You can do that by assigning higher relative priority to the supersystem. See below links for details:https://www.mathworks.com/help/simulink/slref/block-priority.htmlhttps://www.mathworks.com/help/simulink/ug/controlling-and-displaying-the-sorted-order.html#f13-91958 Related QuestionHow can control fault by circuit breakerCumsum till condition is met
Best Answer