[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Numerical Differentiation and Integration of Array Data
From: |
c. |
Subject: |
Re: Numerical Differentiation and Integration of Array Data |
Date: |
Sat, 3 Dec 2011 12:41:35 +0100 |
On 3 Dec 2011, at 11:51, syberraith wrote:
> Those replies helped.
>
> Here is my version of the the central difference algorithm along with a sum
> statement for integrating.
>
> n = 100000; # Number of data points
> p = 0.005; # Time period
> a = 5; # Just a variable parameter
> h = p ./ n; # dt
> g = h ./ 2; # dt/2 for my version of central diff
>
> t = linspace(0, p , n);
>
> f = ( (a .+ sin(1256 .* (t .+ g))) .- (a .+ sin(1256 .* (t .- g))) ) ./ h;
>
> s = sum(h .* (f(1:end-1) .+ f(2:end)) ./ 2)
I think h should be defined as p/(n-1) rather than p/n as it's the distance
between two samples:
t(2) - t(1)
ans = 5.0001e-08
>> p/(n-1)
ans = 5.0001e-08
>> p/(n)
ans = 5.0000e-08
also, you don't need to use '.+' and '.-' they are just synonyms for '+' and '-'
c.
- Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/02
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/02
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/02
- Re: Numerical Differentiation and Integration of Array Data, Jordi Gutiérrez Hermoso, 2011/12/02
- Re: Numerical Differentiation and Integration of Array Data, Jordi Gutiérrez Hermoso, 2011/12/02
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data,
c. <=
- Message not available
- Re: Numerical Differentiation and Integration of Array Data, Carlo de Falco, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/03
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, Carlo de Falco, 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, c., 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, syberraith, 2011/12/04
- Re: Numerical Differentiation and Integration of Array Data, Francesco Potortì, 2011/12/05