math - Java plot values in a virtual graph and find the integral area. -


quick question. got 10 000 lines information. have 2 values on each line. line in format : (time , water speed). want use numerical integration solve how water passed sensor, i'm confused how go solving in java.

i assume graph nice, don't need graphical, maybe array-list trick.

any tips, hint , tricks appreciated.

you can use trapezoidal rule this: sort intervals time, calculate sum follows:

// assume time expressed using class time[] time = ... // assume water speed double, expressed in volume per unit of time. // further assume time units match units in denominator of water speed, // e.g. if speed in galons per minute, time unit minutes; // if speed in galons per second, time unit seconds, , on double[] speed = ...  double sum = 0; (int = 0 ; < time.length-1 ; i++) {     double deltat = time[i+1].subtract(time[i]).totimeunits();     // formula trapezoidal rule on non-uniform grid     sum += (speed[i]+speed[i+1])*deltat; } double totalflow = sum / 2; 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -