[scilab-Users] equivalent of intg on a "discrete interval" (cumsum-like behaviour)

Serge Steer Serge.Steer at inria.fr
Thu Apr 26 18:28:14 CEST 2012


Le 26/04/2012 14:02, Adrien Vogt-Schilb a écrit :
> Hi
>
> Scilab has a proceudre that integrates any given real function or 
> external:
>
>
> [v]=intg(a,b,f)
>
> I have a function f and would like to calculate the integral for a set 
> of values , say in A:B
>
> Does anyone know if there is something more efficient than a loop on b 
> to do? Currently I do this:
>
> segment = A:B;
>
> for i=1:size(segment,"*")
>     [v(i)]=intg(A,segment(i),f)
> end
>
> It's a shame, because I guess that that there should be a way to 
> optimize what intg does in this case
>
>
> -- 
> Adrien Vogt-Schilb (Cired)
> Tel: (+33) 1 43 94 *73 77*
The following code should be more efficient
for i=2:size(segment,"*")
     v(i)=intg(segment(i-1),segment(i),f)
end
v=cumsum(v)

Serge Steer

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20120426/5729afab/attachment.htm>


More information about the users mailing list