[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Integration with constants?
From: |
Jens Benecke |
Subject: |
Re: Integration with constants? |
Date: |
Mon, 13 Nov 2006 10:23:51 +0100 |
User-agent: |
KNode/0.10.4 |
John W. Eaton wrote:
> | > | [J2, ier, nf, err] = quad(@(x) log( ...
> | > | sqrt(1 + alpha.^2 + 2.*a.pha.*cos(2.*x)) + alpha + cos(2.*x)
> | > | ), 0, pi/2, 1e-6)
> | > | "alpha" is a constant that has been calculated before. However,
> | > | Octave tells me "error: alpha undefined ..."
> | Sorry ... 2.1.72, on SuSE Linux.
> | Any way to do this with the 2.1 branch?
>
> In that case, I think the only option is a separate function and
> global variables.
Hi,
I tried this - setting "alpha" to global, then executing my function:
38 global alpha = R2./R1 -> returns 1.2286
39 kii = sqrt(4.*alpha ./ (1+alpha).^2) -> works fine
40
41 isglobal('alpha') -> returns 1
42 function res = Ji1(x)
43 res = log( ...
44 ( sqrt(1 + alpha.^2 + 2.*alpha.*cos(x)) + 1 + alpha.*cos(x) ) ./ ...
45 ( sqrt(1 + alpha.^2 + 2.*alpha.*cos(x)) + alpha.*sin(x) - 1 ) )
46 end
47
48 [J1, ier, nf, err] = quad('Ji1(x)', 0, pi/2, 1e-6)
Result:
error: `alpha' undefined near line 44 column 13
error: evaluating binary operator `.^' near line 44, column 18
error: evaluating binary operator `+' near line 44, column 11
error: evaluating binary operator `+' near line 44, column 22
error: evaluating argument list element number 1
error: evaluating binary operator `+' near line 44, column 42
error: evaluating binary operator `+' near line 44, column 46
error: evaluating binary operator `./' near line 44, column 64
error: evaluating argument list element number 1
error: evaluating assignment expression near line 43, column 5
error: called from `Ji1'
error: evaluating assignment expression near line 48, column 34
error: called from `__quad_fcn_Q__'
error: quad: evaluation of user-supplied function failed
I'm a bit lost here... =;()
--
Jens Benecke
Please do not carbon copy me, I read the lists I post in!