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

Import txt data to Modelica(how to use CombiTimeTable)

Import txt data to Modelica(how to use CombiTimeTable)

Hello again,

I d like to import a data file from an excel data sheet. The data are the rotation angles of an axis q(t) (a 500+rows data sheet).

So let's say i have tranfered the data to a txt file and they are of the format

t               q
0.01        1
0.02        1.2
0.03        1.4
0.04        1.9
......

Where t is the time in sec and q the angle in rad

I would like to launch a simulation taking the values from txt file (with linear interpolation between values for a continuous time simulation)

i guess i should use the Time Table or CombiTimeTable but can someone quide my through the proccess

Thanks in advance

Edited by: ksenagos - Jul-21-14 17:17:59

Re: Import txt data to Modelica(how to use CombiTimeTable)

Hi,
I'm trying around myself with the CombiTimeTable at the moment. I managed to get it to work in general. Try this example:

 Spoiler Show Spoiler Hide Spoiler
 model CombiTimeTableTest       
  annotation(Icon(coordinateSystem(extent={{-100.0,-100.0},{100.0,100.0}}, preserveAspectRatio=true, initialScale=0.1, grid={10,10})), Diagram(coordinateSystem(extent={{-297.0,-210.0},{297.0,210.0}}, preserveAspectRatio=true, initialScale=0.1, grid={5,5})));
  Modelica.Blocks.Sources.CombiTimeTable combiTimeTable1(fileName="cycle.txt", tableName="tab1", tableOnFile=true, smoothness=Modelica.Blocks.Types.Smoothness.ContinuousDerivative) annotation(Placement(visible=true, transformation(origin={-45.0,128.2828}, extent={{-10.0,-10.0},{10.0,10.0}}, rotation=0)));
end CombiTimeTableTest;
Here's the example data file (save it as cycle.txt in the same direction as you save the *.mo-file, if you save it in another directory, you have to give the full path to the file):

 Spoiler Show Spoiler Hide Spoiler
 #1
double tab1(22,2)
0.1    60
100    60
102    5
200    5
240    60
300    60
310    60
320    110
330    70
345    80
360    60
450    60
460    20
600    20
610    40
1000    40
6000    40
6100    200
6300    200
6400    5
6500    5
6700    60
The CombiTimeTable seems to be kinda buggy though, at least in Wolfram SystemModeler. Sometimes I can't open a file that just before worked sweet. And after restart it works fine again. Please report whether you have issues like this, too so I can work out if this problem is WSM- or Modelica-specific.

Re: Import txt data to Modelica(how to use CombiTimeTable)

Thanks

It works fine so far

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