- Index
 - » Programming
 - » Modelica Language
 - » Changing equations permanently
 
Page Start Prev 1 Next End
Changing equations permanently
Changing equations permanently
Feb-16-13 02:42:03
  I have a problem that should be easy but I could not solve.
I want to write a block  that receives x as input and creates y.
It should be:
     y =0                  up to when x > xMax for the first time
and: 
     y=1                  after that.
It should be  y=1 even if later x is back below xMax.
Someone can help?
- ceraolo
 - 
 - 
 - 147 Posts
 
Re: Changing equations permanently
Feb-16-13 09:31:37
 
Code:
model M
Real x,y(start = 0.0);
parameter Real xMax = 0.5;
equation
der(x) = sin(time);
when x > xMax then
y = 1.0;
end when;
end M;
- sjoelund.se
 - 
 - 
 - 1700 Posts
 
Re: Changing equations permanently
Feb-17-13 10:11:50
  Thanks.
It  is easy and effective.
The when clause indeed opens to me a new world of  options and possibilities.
MC
- ceraolo
 - 
 - 
 - 147 Posts
 
Page Start Prev 1 Next End
- Index
 - » Programming
 - » Modelica Language
 - » Changing equations permanently
 
	There are 0 guests	and 0 other users also viewing this topic	
						 Thank you 
						