help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

how to do trapz on a data file


From: Nunzio Losacco
Subject: how to do trapz on a data file
Date: Sat, 17 Oct 2009 18:19:06 +0200

Hi everyone,

I've just installed octave 3.2.3 and I'm a complete newbie. What I need most is a quick command to get the area under a curve. The curve is made of columns 1 and 3 of a file like this which I use to plot with gnuplot:

1.000000000000e+02 0.000000000000e+00 6.917126169316e-04
9.798418000000e+01 0.000000000000e+00 6.923512999807e-04
9.596836000000e+01 0.000000000000e+00 6.947493914720e-04
9.400841000000e+01 0.000000000000e+00 7.045027864544e-04

and so forth...

I use to import the file in a spreadsheet and then do a trapezoidal integration "by hand"

sum((y[i-1]+y[i])*(x[i]-x[i-1])/2) for i=2:n

being i the row and n the number of rows.

But this is very time wasting when doing loads of parametric analyses. How can I get this quickly with octave?
There would be any difference if the file had a header?

Thanks for your help,

N.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]