help-octave
[Top][All Lists]
Advanced

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

Re: quadl can't integrate sin or cos over a period


From: Søren Hauberg
Subject: Re: quadl can't integrate sin or cos over a period
Date: Tue, 08 Jul 2008 08:58:40 +0200

tir, 08 07 2008 kl. 00:41 -0400, skrev Adam Higuera:
> As a general question, is there any workaround to pass additional parameters 
> to
> the function I am integrating without using quadl (where extra parameters to
> quadl are passed directly to the function)?  quad lacks this functionality.

You can simply redefine the function you want to integrate. Say you want
to integrate

  f (x, alpha, beta) = sin (alpha * x + beta)

where alpha and beta are parameters. Then you can do something like

  alpha = 2;
  beta = 1;
  f = @(x) sin (alpha .* x + beta);

and then

  quadl (f, 0, 2*pi)

Søren

P.S. This code is totally untested as I just typed it directly into this
e-mail, so you might need to fix a bug here and there...



reply via email to

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