help-octave
[Top][All Lists]
Advanced

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

Re: Bessel function with octave(answer Bard Skaflstad)


From: Bård Skaflestad
Subject: Re: Bessel function with octave(answer Bard Skaflstad)
Date: Thu, 18 Aug 2011 16:36:32 +0200

On Thu, 2011-08-18 at 13:23 +0200, john wrote:
> Hi,
> 
> Thank you very much for your help.I tried this
> 
> function y=besintj0(x)
> global x
> y=1/pi*quad(@bintegra,0,pi); thats line 18 of besintj0
> endfunction
> 
> 
> function y=bintegra(q)
> global x
> y=(cos(x.*sin(q));thats line 4 of bintegra(here the error product
> nonconformant.
> endfunction
> 
> when I run this application I get the following error:

[ snip ]

> error: product: nonconformant arguments (op1 is 0x0, op2 is 1x13)
> error: evaluating argument list element number 1

[ snip ]

I looked it up.  The error is apparently caused by naming your 'global'
the same as the formal input parameter to 'besintj0'.  This is ambiguous
and confuses Octave (and MATLAB for that matter).

If you want to continue to use GLOBAL, I recommend changing your
'besintj0' function into something along the lines of

        function y = besintj0(x0)
          global x
          x = x0;
          y = quad(@bintegra, 0, pi) / pi;
        endfunction

That way you avoid the ambiguous definition of the GLOBAL symbol.


Sincerely,
-- 
Bård Skaflestad <address@hidden>
SINTEF ICT, Applied Mathematics



reply via email to

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