hexagon logo

Spline with formula behind

Hello everyone,
 
 
My model, developed with ADAMS View, has a marker called "Origin" with coordinates {0.0, 0.0, 0.0} and a second marker called "Relative".
 
I am using 2 measurements in order to plot the displacement of Relative on Y direction, but related to the Origin.
Also the displacement of Relative on Z direction, but related to the same Origin.
 
Both 2D splines have approx. 2000 points on each column.
 
I want to generate a 3rd spline by using the data from previous measurements.
This new spline will have a formula behind :
 
 
Relative.Y (1st point) - Relative.Y (2nd point) + Relative.Z (1st point) - Relative.Z (2nd point)
 
then,
 
Relative.Y (2nd point) - Relative.Y (3rd point) + Relative.Z (2nd point) - Relative.Z (3rd point)
 
then,
 
Relative.Y (3rd point) - Relative.Y (4thd point) + Relative.Z (3rd point) - Relative.Z (4thd point)
 
and so on until
 
Relative.Y (1999th point) - Relative.Y (2000th point) + Relative.Z (1999th point) - Relative.Z (2000th point)
 
 
In Excel I could do that very easy, but now I want to generate this in ADAMS either.
 
I would prefer to have a simple equation, instead of 2000 equations Joy ... I do not know... something with while loop... I guess....
 
Can you please give me some recommendations how to write this formula ?
 
Many thanks! Regards,
Daniel
Parents
  • You can't create this inside the model. It has to be a macro or command file that you execute (read in) after the analysis is done. This code creates a new view variables with all the values you are asking for.
     
    var set var=new_values real=0.0
    for var=ii start=1 end=(eval(COLS(.sample.Last_Run.Relative_Y.Q)-1))
     var set var=jj int=(eval(int(ii)))
     var set var=new_values index=(eval(jj)) &
      real=(eval(.sample.Last_Run.Relative_Y.Q.values[jj]-.sample.Last_Run.Relative_Y.Q.values[jj+1]+.sample.Last_Run.Relative_Z.Q.values[jj]-.sample.Last_Run.Relative_Z.Q.values[jj+1]))
    end
     
    Copy this to a file "new_values.cmd". After you run the simulation, press F2 and read in this file.
Reply
  • You can't create this inside the model. It has to be a macro or command file that you execute (read in) after the analysis is done. This code creates a new view variables with all the values you are asking for.
     
    var set var=new_values real=0.0
    for var=ii start=1 end=(eval(COLS(.sample.Last_Run.Relative_Y.Q)-1))
     var set var=jj int=(eval(int(ii)))
     var set var=new_values index=(eval(jj)) &
      real=(eval(.sample.Last_Run.Relative_Y.Q.values[jj]-.sample.Last_Run.Relative_Y.Q.values[jj+1]+.sample.Last_Run.Relative_Z.Q.values[jj]-.sample.Last_Run.Relative_Z.Q.values[jj+1]))
    end
     
    Copy this to a file "new_values.cmd". After you run the simulation, press F2 and read in this file.
Children
No Data