[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Integration with constants?
From: |
John W. Eaton |
Subject: |
Integration with constants? |
Date: |
Sat, 11 Nov 2006 09:08:28 -0500 |
On 11-Nov-2006, Jens Benecke wrote:
| I am trying to integrate a function that has constants previously defined in
| the same matlab file. Like this:
|
| [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 ..."
|
| Do I have to write a seperate .m file for each function I want to be able to
| integrate? I thought it was possible using the "@(x)" anonymous function
| syntax.
|
| I would appreciate any help or pointers to the right documentation. Thank
| you!
What version of Octave are you using? This works in 2.9.9:
octave:1> a = 2
a = 2
octave:2> quad (@(x) x + a, 0, 1)
ans = 2.5000
jwe