Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I'm trying to make a binary switch that switches after a fixed given interval. Why doesn't the following work:

step = .1;
t = Dynamic[Clock[{0, 5, step}, 5, 1] ]; 
Dynamic[t >=  2]
share|improve this question
    
Could someone with at least 300 points of reputation please add some more tags? –  zab Apr 28 at 12:57
1  
Dynamic[Clock[] > .5] –  Vitaliy Kaurov Apr 28 at 13:10

2 Answers 2

up vote 8 down vote accepted

Note that you've defined t as a Dynamic expression. A relational operator like GreaterEqual (>=) works with numeric expressions like the result of Clock. You could try something like this to get a displayed output that eventually switches from False to True:

step = .1;
Dynamic[{t, t = Clock[{0., 5., step}, 5., 1]; t >= 2}]
share|improve this answer
    
Thanks so much! –  zab Apr 28 at 13:18

I couldn't help thinking about this question even after I voted for billsphere's perfectly satisfactory answer. Finally, I concluded that Trigger would be a better way to implement the requested functionality. It is just as easy to use as Clock and throws in a nice little control panel as a bonus.

With[{dt = 1, tmax = 10, threshold = 4}, 
  Column[{
    Dynamic @ Row[{t, " > ", threshold, " is ", t > threshold}],
    Trigger[Dynamic @ t, {0, tmax, dt}, dt]}]]

trigger

share|improve this answer
    
@ m_goldberg, nope, Trigger doesn't work on the Linux version :-( –  zab May 2 at 2:36

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.