In Matlab, I want to create a while loop that keeps running until the difference
ID: 3839808 • Letter: I
Question
In Matlab, I want to create a while loop that keeps running until the difference between any 2 points in an array is less than 7. I know what to put inside the actual loop. I just don't know how to word it so the loop stops running if there's a difference of 7 between any 2 points in this array. Please help. In Matlab, I want to create a while loop that keeps running until the difference between any 2 points in an array is less than 7. I know what to put inside the actual loop. I just don't know how to word it so the loop stops running if there's a difference of 7 between any 2 points in this array. Please help. In Matlab, I want to create a while loop that keeps running until the difference between any 2 points in an array is less than 7. I know what to put inside the actual loop. I just don't know how to word it so the loop stops running if there's a difference of 7 between any 2 points in this array. Please help.Explanation / Answer
I am writing the pseudocode for the loop, please change it to matlab's syntax. While loop stops if flag becomes false i.e. if there is any two points such that their difference is less than 7.
flag = True;
for i = 0: length(array):
for j = i+1 : length(array)
diff = array[i] - array[j];
if diff < 0 then diff = diff*( -1)
if diff < 7:
flag = False;
while( flag )
DO YOUR WORK HERE
for i = 0: length(array):
for j = i+1 : length(array)
diff = array[i] - array[j];
if diff < 0 then diff = diff*( -1)
if diff < 7:
flag = False;
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.