Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am attempting to Append a new value into my list paramMonitor whenever the value for B changes. I had the code working perfectly, but my computer crashed without saving the document. I am now having a lot of trouble (dynamically) appending these values to my list.

My attempts:

  • This updates B but does nothing to append the value {B, e, some number} to paramMonitor

              {B,e,Abs[model[B, e][#] & /@ test[[All, 1]] - test[[All, 2]]] // Total}]


  • Removing the first argument 'B', this code fails to compile and simply aborts upon execution:

             {B,e, Abs[model[B, e][#] & /@ test[[All, 1]] - etst[[All, 2]]] // Total}]

I believe this is a quick fix (since I had it working earlier), but I cannot seem to find the issue.

share|improve this question
Before I will update the answer, please tell me how B can be changed? I mean, it is tied to some kind of controller or it is just a global variable that can be change anywhere? – Kuba Apr 24 '14 at 11:15
Sorry about the late response. B is changed through NonLinearModelFit (NLMF). NLMF is finding the best fit values for B and e. I have NLMF's EvaluationMonitor printing "B and e values" to the screen. So, at every new evaluation step, Dynamic[B] will update. Thanks for all the help!! – ABBOUDR Apr 29 '14 at 18:32
So my answer does not fit your needs quite well, right? – Kuba Apr 29 '14 at 18:36
Unfortunately not. Since NonlinearModel takes a very long time to evaluate, I wanted a way to monitor its progress in Real-Time. My other option is to add some commands within EvaluationMonitor, like this – ABBOUDR May 1 '14 at 0:51

The most important thing, and the thing that can be easily missed is that the second argument of Dynamic must be a function or a list of functions:

list = {};
Slider[Dynamic[b, (b = #; list = Join[list, {b}]) &], {1, 10, 1}]

enter image description here

share|improve this answer
Another thing that can be easily missed is that the second argument of Dynamic only seems to work reliably when the Dynamic expression is evaluated as an argument of a control or other GUI element (like the slider you used in your example). I have found that the front-end does seem to like a naked Dynamic with a 2nd argument when it encounters one at top-level such as in the example the OP gave. – m_goldberg Apr 24 '14 at 8:01
@m_goldberg good point, I have not though he tried to do that this way. It seems I have to write a little bit more. :) – Kuba Apr 24 '14 at 9:15
@m_goldberg: you say "only seems to work reliably", but does it work at all and is it supposed to? I would have said it most probably isn't even meant to work, but honestly don't know what actually is the "documented" behavior that I could expect. I also can't see that a naked Dynamic with a 2nd argument does anything relevant concerning its 2nd argument, other than quietly ignoring it. Am I missing something here? – Albert Retey Apr 24 '14 at 14:09
@AlbertRetey. I used tentative language because I don't know for sure. From my reading of the docs and my own experiments, I think it likely that the 2nd argument of Dynamic is not intended to be used at top-level the way the OP of this question did. My experience with naked Dynamic is exactly as you say. BTW, there is a typo in my comment. I meant to say: "does not seem to like a naked Dynamic" – m_goldberg Apr 24 '14 at 14:44
@AlbertRetey I agree with you, it's meant to cooperate with controllers: "during interactive changing or editing of val." I think that m_goldberg pointed that OP tried to use it in "naked" Dynamic. I'm waiting for confirmation from OP. :) – Kuba Apr 24 '14 at 14:44

Your Answer


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.