Team:Groningen/Modelling/model/calc.js

From 2009.igem.org

(Difference between revisions)
Line 99: Line 99:
     setOutput(ModelAnswer, i);
     setOutput(ModelAnswer, i);
-
 
-
 
   }
   }
-
 
-
 
-
 
-
 
}
}

Revision as of 12:00, 25 August 2009

function calc(){

 //  gets input
 var growthFactorNode = document.getElementById("growthFactor");
 // reads input
 var growthFactor = Number(growthFactorNode.value); 
 
 // begin variable
 var time = 0;
 var x = 0;
 var y = 0;
 arrValueX = new Array();
 arrValueY = new Array();


 // process
 var growthFactor = growthFactor + 1;
 for (var time = 0; time < 30; time++) {
   var y = growthFactor*x*x;
   var x = x + 1;
   arrValueX.push(x);
   arrValueY.push(y);
 }
 
 // Set outputs
 setOutput(growthFactorAnswer, growthFactor ); 
 document.getElementById('growthFactorGraph').refresh();

}


function setOutput(node,v) {

 node.innerHTML = formatNumberToHTML(v);
 node.value = v;

}


function formatNumberToHTML(v,p) {

 if (p===undefined) p = 5;
 return v.toPrecision(p)
         .replace(/e\+([0-9]+)$/i,'·10$1')
         .replace(/e\-([0-9]+)$/i,'·10-$1');

}


// ------ Annelies timer functie ---------

// function tijd(){ // setTimeout( "doSomething()", 3000 ); // }

// function doSomething(){ // if (doSomething.time === undefined) { // doSomething.time = 0; // } // // // Set outputs // setOutput(tijdAnswer, doSomething.time); // doSomething.time += 1; // // if (doSomething.time<=100) setTimeout( "doSomething()", 3000 ); // }



// -------- transport ----------

// var myCars=new Array();

function transport(){

// variablen
 var timeAr =new Array();
 var AsInAr =new Array();
 var ArsBAr =new Array();
 var ArsExAr =new Array();
 var GlpFAr =new Array();
 var GlpFAsAr =new Array();
 var ArsBAsAr =new Array();

// constanten

 var tolalTime = 300;
 var stepSize = 3;
 var timeBegin = 0;
 var AsInBegin = 0;
 var ArsBBegin = 5;
 var ArsExBegin = 5;
 var GlpFBegin = 5;
 var GlpFAsBegin = 0;
 var ArsBAsBegin = 0;
 var N = tolalTime / stepSize ;
 var i;
 for (i=1;i==N;i++){
   setOutput(ModelAnswer, i);
 }

}