[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: definite integral of arbitrary function
From: |
Juan Pablo Carbajal |
Subject: |
Re: definite integral of arbitrary function |
Date: |
Sat, 28 Apr 2012 03:07:56 +0200 |
On Sat, Apr 28, 2012 at 1:13 AM, rdurkacz <address@hidden> wrote:
> At first I thought this was exactly the right answer but now I have had
> second thoughts. In your example
> sin() is a good octave function in that it works over vectorised arguments,
> ie sin (sin ([0:0.1:1])
> works. Then we hope to obtain the definite integral of sin by using the
> transform adiff(), and we have the function c()
> c(pi) works but c([0:0.1:1]) fails, it is not vectorised. c() is not as good
> a function as sin(). The Paul Thomas post from years ago is relevant-- since
> I want a vectorised result I would have to write some kind of loop involving
> quad -so lsode looks better.
> I say c([0:0.1:1]) fails -the result is "warning: implicit conversion from
> real matrix to real scalar, ans=0" which is disappointing at least, if not a
> failure.
>
>
>
>
> --
> View this message in context:
> http://octave.1599824.n4.nabble.com/definite-integral-of-arbitrary-function-tp4578474p4593932.html
> Sent from the Octave - General mailing list archive at Nabble.com.
> _______________________________________________
> Help-octave mailing list
> address@hidden
> https://mailman.cae.wisc.edu/listinfo/help-octave
You can vectorize the solution that was provided. For scalar
inputs/outputs you can use arrayfun, for more complex inputs, you will
have t convert them to cells using mat2cell and then apply celfun, and
then the inverse with the outputs.
For example
function af = adiff(f)
af = @(x) arrayfun (@(t)quad(f, 0, t), x);
endfunction
--
M. Sc. Juan Pablo Carbajal
-----
PhD Student
University of Zürich
http://ailab.ifi.uzh.ch/carbajal/