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

Modelica Scripting Language

Modelica Scripting Language

Hi,
Modelica scripting language have math library such as ABS(value), MAXIMUM(array)  e.t.c. ?

Thanks

Oki

Re: Modelica Scripting Language

current/smile
got it thanks
Oki

Re: Modelica Scripting Language

Ok, How can append result value to array?

Code:


for i in 0:6 loop
v:=abs(val(TABLO.y[1],i*1000)-val(vMetre.v,i*1000));
end for;

Re: Modelica Scripting Language

https://build.openmodelica.org/Document … ()%27.html

Or just fill an array before the loop so you can assign each element (much faster; cat is expensive).

Code:

arr := fill(0.0, 6);

for ... loop
  arr[i] := ...;
end for;

Re: Modelica Scripting Language

  current/smile  Thanks again
Oki

Re: Modelica Scripting Language

Code:


arr := fill(0.0,6);
for i in 0:6 loop
arr[i]:=abs(val(TABLO.y[1],i*1000)-val(vMetre.v,i*1000));
print arr[i];
end for;
print max(arr);

when run script i got; Error: Parse error: Only function call expressions may stand alone in an algorithm section
before use arr() i have to define or something?

Oki

Re: Modelica Scripting Language

I mean i know print only stdout,
When i try to write array to file i got nothing,

Code:

for i in 0:6 loop

arr[i]:= abs(val(TABLO.y[1],i*1000)-val(vMetre.v,i*1000));
end for;
writeFile("c:/loop/log.txt",String(arr[0])+"\n",append=true);

log.txt  is never create w/o any error. But for testing purposes i try;

Code:


for i in 0:6 loop
arr[i]:= abs(val(TABLO.y[1],i*1000)-val(vMetre.v,i*1000));
end for;
writeFile("c:/loop/log.txt",String(11)+"\n",append=true);

log.txt   created and inside data 11.

There are 0 guests and 0 other users also viewing this topic