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

Multiply variable by a constant?

Multiply variable by a constant?

Hello

I'm new to modelica. I've made a simple model used to simulate planets orbits. The moons orbit around the earth, is very small compared to the earth orbit around the sun. So when I make a plot I can't see the moons motion very clear. I would like to make an exaggerated new variable that i 20 times the moons coordinates. However if the variable of the moons orbits i saved in the array x[3], then declaring a new variable x2[3] and adding the equation

x2 = 20*x

does nothing, and I can't even see the variable x2 under the plotting tab. Everything else is working perfectly.

I guess it has something to do with the way modelica handles equations. I'm trying to use it like at regular programming language here, and maybe modelica is looking at it as a non-important equation because it ads nothing new to the set of equations.

So my question is, how do I make my new variable that is just a scaled version of my original variable?

Hope someone can help me

Re: Multiply variable by a constant?

Hello MrAndersDk

As you say you are new, maybe there is a problem around there.
Have you tried simply to multiply every element of the array with a "for"?

Best regards
Koldo

Re: Multiply variable by a constant?

Real x[3] , x2[3]

equation

x = {1,2,3};
x2 = 20*x;

This has worked. Declare x2 also as a Real variable. If it doesn't work, do share your code so that we can have a look.

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