OpenModelica


Forgot password? | Forgot username? | Register

counter

counter

Hi,
I want to count up real parameter during if condition happen.
But i got simulation crashed.
Please help, Thanks

Code:


Real x (starr=1);
equation
  if out1 then
    x = x+1;
  else
    x=1;
  end if;

Administrator has disabled public posting. Please login or register in order to proceed.

Re: counter

You want a when-equation to count discrete changes. http://book.xogeny.com/behavior/discrete/when/

Code:

when out1 then

  x = pre(x) + 1;
end when;

x = x + 1 is a hard equation to satisfy since it is identical to 0 = 1.

Administrator has disabled public posting. Please login or register in order to proceed.
There are 0 guests and 0 other users also viewing this topic