MATLAB: How to reject of the next value less than the previous one

how to reject of the next value less than the previous one

Hi to all the Matlab users, I have made a program in which I want to accept the value in a loop which is less than the previous one. Kindly advise. e.g. if first value at the start of the loop is 10 then next value comes 10.3 next 9.6….. I want that 10.3 should be rejected and 9.6 gets accepted and so on……… Kindly suggest….. Regards…..

Best Answer

Not sure what you mean by reject, but will the following be of any help?
x=10;
while true
newvalue = 20*rand;
if newvalue > x
x = newvalue;
end
end