- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Can Modelica solve ax+b linear...
Can Modelica solve ax+b linear equation ?
Re: Can Modelica solve ax+b linear equation ?
Yes, modelica can solve linear equations. But to solve linear equations, the number of unknowns should be equal to the number of equations. In your model x and y are the unknown variables. And "y = a*x +b" is the only equation. So there are two unknowns and only one equation. You should either define one of the two unknown variables or give another equation.
for eg:
model Linear
parameter Real a=2;
parameter Real b=1;
parameter Real y = 9;
Real x;
equation
y=a*x + b;
end Linear;
or
model Linear
parameter Real a=2;
parameter Real b=1;
Real y;
Real x;
equation
y=a*x + b;
y = b*x + a;
end Linear;
- knkc
-
-
- 14 Posts
Re: Can Modelica solve ax+b linear equation ?
I appreciate your feedback, however I am looking to plot the evolution of y over values of x from 0 to 10 for example (y=f(x)) and not just solve the equation. So I should probably define the range of values for x. Is that doable ?
Re: Can Modelica solve ax+b linear equation ?
Maybe like that:
Code:
model linearEquation
parameter Real a=2;
parameter Real b=1;
Real x = time;
Real y;
equation
y = a*x+b;
annotation(experiment(StopTime = 10));
end linearEquation
so long.
Willi
- wbraun
-
-
- 75 Posts
Re: Can Modelica solve ax+b linear equation ?
But on what should the rising depend on?
You can have an input:
Code:
model linearEquation
parameter Real a=2;
parameter Real b=1;
input Real u;
Real x(start=0);
Real y;
equation
x = u;
y = a*x+b;
annotation(experiment(StopTime = 10));
end linearEquation
Or depending on time in a different order:
Code:
model linearEquation
parameter Real a=2;
parameter Real b=1;
Real x(start=0);
Real y;
equation
der(x) = if x>=10 then 0 else 1;
y = a*x+b;
annotation(experiment(StopTime = 10));
end linearEquation
so long.
Willi
- wbraun
-
-
- 75 Posts
- Index
- » Usage and Applications
- » OpenModelica Usage and Applications
- » Can Modelica solve ax+b linear...