Group Abstract Group Abstract

Message Boards Message Boards

[?] Avoid troubles when using WhenEvent?

Dear Friends

I am implementing a digital controller using the function WhenEvent

SolH = NDSolve[{EqnsC, InitsC, control}, VarsC, {t, 0, tf}, 
   DiscreteVariables -> \[ScriptD][t]];
Plot[{Subscript[\[ScriptI], \[ScriptL]][t], \[ScriptD][t]} /. 
  SolH, {t, 0.0025, tf}]

the control input is updated every h seconds

h = 0.00001;
control = WhenEvent[Mod[t, h] == 0, \[ScriptD][t] -> ucontrol];

The simulation develops well when ucontrol= constant but it does not when I plug in my design function. It seem that the control which a large function of systems states reminds unevaluated. What I am doing wrong? I have followed the documentation.

Hopefully someone out there will have a suggestion.

I am including a notebook that contains the system specifications.

Best regards

Jesus

Attachments:
3 Replies

Jesus,

It's not obvious, nor is it easy to explain!

You're welcome & best wishes,

Michael

POSTED BY: Michael Rogers

Michael

Thank you very much! Your correction did solve my problems. The solution is not intuitive or something that can be easily inferred from the documentation. So, thanks. I really appreciate it.!

Jesus

POSTED BY: Michael Rogers
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard