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

Getting time

Getting time

Hello ,
i want to get the time of the simulation when the event is appened.

For example:
i have the variable x(t) that goes from 0 to 2 and i want to get the time when x =1.5.
I write on modelica this code.

when x == 1.5 then
T = time;
end when;

This code doesn't work.

Where am i failing?

Tnks

Re: Getting time

Hi,

try

Code:


when x >=1.5 then
  T = time;
end when;

Using the "==" on real number will result in a Translation Warning. Maybe thats why it doesn't work.

Re: Getting time

Tnks for answered. In the end i resolve with a timer wich start when the condition x==1.1 is sodisfied using a boolean variable.

I don't used:

when x>= 1.1 then
T=Time;
end when ;

because the time variable T will updaiting time by time for every second that x will be over than 1.1.

There are 0 guests and 0 other users also viewing this topic
You are here: