Thursday, 15 March 2012

Why doesn't this timed while loop work (Matlab)? -



Why doesn't this timed while loop work (Matlab)? -

i semi-advanced , don't understand why code not execute properly. want code execute @ time. input. /hank

running=1; while running==1 if hour(now)==17 & minute(now)==4 & second(now)==59 (do stuff) running=0; end end

it's because second returns double array, , floating point double precision, status second(now)==59 may never true. replace like: abs(second(now)-59)<1e-3 or whatever threshold think appropriate. values returned hour , minute integer, equality test should valid.

matlab while-loop

No comments:

Post a Comment