Book a Demo

Author Topic: Help! A simulation problem with EA!  (Read 4828 times)

Volkan

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Help! A simulation problem with EA!
« on: June 15, 2016, 11:41:18 pm »
Hi! I am a beginner in learning EA system engineering edition.
I practiced establishing a model using SysML. I want to simulate a constraint block for practice. The constraint block is intended to centre a very simple array [1,2,3,4].
I added some JavaScript to the constraint block and established a parametric diagram and then did the simulation. But I got nothing in the simulation result.
When I just changed the JavaScript into "OutputT=OutputT;" and output the input array, the simulation result was correct. Is there something wrong with my JavaScript?
Could someone please help me with this problem? Are there any tutorials on adding JavaScript to constraint blocks? Thank you in advance!

The following is the JavaScript I added:

var aa=new Array();
var sum;
var avg;
var mean=new Array();

aa=InputT;   //InputT is an array, the value is =[1,2,3,4];


for(var i=0;i<4;i++)

     sum+=aa;
}

avg=sum/4;    //Calculate the mean value of aa.

for(var i=0;i<4;i++)
{
  mean=avg;
}

aa=aa-mean; // Subtract each element in aa by the mean value.

OutputT=aa; //Output

Volkan

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Help! A simulation problem with EA!
« Reply #1 on: June 16, 2016, 11:58:26 pm »
Mainly it is because I did not set the proper input as the X-Axis value.

Volkan

  • EA User
  • **
  • Posts: 26
  • Karma: +0/-0
    • View Profile
Re: Help! A simulation problem with EA!
« Reply #2 on: June 19, 2016, 11:34:10 pm »
Another important reason: the javascript  that I added to the constrained blocks does not support the self-defined datatype vector using sysml.  :'( :'( :'(