- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » relation problems
Page Start Prev 1 Next End
relation problems
relation problems
Apr-01-11 10:05:39
i want create a ratio between i1 and i2 this ratio should have a range from 0 to 1
so i try
Code:
ratio=smooth(2, if i1>i2 then
i2/i1 else
i1/i2);
but ratio reaches a value of round about 1.049 so i tried
Code:
helpratio=smooth(2, if i1>i2 then
i2/i1 else
i1/i2);
if helpratio>1.0 then
ratio=1.0 else
ratio=helpratio
end if;
but again ratio reaches round about 1.049
then i tested if the second if loop is used
Code:
helpratio=smooth(2, if i1>i2 then
i2/i1 else
i1/i2);
if helpratio>1.0 then
ratio=1.0 else
ratio=1.0
end if;
then ratio was always 1 but now helpratio has the expected characteristics(between 0 and 1) What i have done wrong?
Re: relation problems
Apr-01-11 10:13:51
Does the following do what you want?
Code:
class A
Real x = 2-8*time;
Real y = 1+time^2-time;
Real ratio = abs(if noEvent(abs(x)>abs(y)) then y/x else x/y);
end A;
- sjoelund.se
- 1700 Posts
Page Start Prev 1 Next End
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » relation problems
There are 0 guests and 0 other users also viewing this topic