[Top][All Lists]

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

Re: New Users - Integrate Data

From: Ben Perston
Subject: Re: New Users - Integrate Data
Date: Fri, 7 Dec 2007 17:22:08 +0000

On 06/12/2007, Ciaran Mooney <address@hidden> wrote:

Is there a way of giving Octave a list of values (x, y) and then
getting it to integrate those values? I have over 600 values so an
even better way would be for octave to import a list of values from a
file, and then perform the calculation.

To elaborate on Michael's response... put your data in a file in comma-separated format (or something like it), so

Then open Octave and load your data:
data = ""
x=data(:,1); y=data(:,2);

And do the integration with trapz

trapz uses trapezoidal integration, i.e. it joins adjacent points with lines, forming a bunch of trapezoids. There are a million other ways to do it but this is probably the easiest.

If your x spacing is constant then you can just take the sum of all the y values and multiply it by the difference between adjacent points in x. I guess that's the rectangular approximation... a bit worse than the trapezoid, but it may not matter depending on the accuracy you need. You can do that calculation easily in a spreadsheet (but you should still start using Octave anyway).


reply via email to

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