Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


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;

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.

There are 0 guests and 0 other users also viewing this topic