[Top][All Lists]

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

Re: Few questions (convolutions, 'mapping', linspace)

From: John Eaton
Subject: Re: Few questions (convolutions, 'mapping', linspace)
Date: Mon, 16 May 94 14:31:32 EDT

address@hidden (Przemek Klosowski) wrote:

:  - I want to convolute the theoretical function S(Q,w) with the experimental 
:    resolution r(w), to compare the resulting Sr(Q,w) with experimental data. 
:    The formula is:
:                   w0
:                   /
:       Sr(Q,w) =   |  S(Q,w-v) r(v) dv 
:                   /
:                  -w0
:    I was hoping to use the quad("fun",-w0,w0), where fun would be defined
:    as 'function y=fun(x); y=S(Q,w-x)*r(x); endfunction'. This didn't quite
:    work, as I need to access Q,w from within that function. I can't pass
:    them as parameters of fun() because quad() expects only one-parameter fun;
:    I couldn't figure the way to pass them as globals either.

It should work to write

  function y = S (Q, w, v)
   y = ...

  function y = r (v)
   y = ...

  global Q;
  global w;

  Q = ...
  w = ...

  function y = fun (x)
    global Q;
    global w;
    y = S (Q, w-x) * r (x);

  w0 = ...

  quad ("fun", -w0, w0)

If this fails, please send a complete bug report to bug-octave.



reply via email to

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