[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Integration with parameters
From: |
Richardson, Anthony |
Subject: |
RE: Integration with parameters |
Date: |
Tue, 16 Mar 2010 10:59:39 -0500 |
See the online documentation on Anonymous Functions (Section 11.9.2
in my version of the documentation). There is an example illustrating
how to do exactly what you want to do:
a = 1;
b = 2;
quad (@(x) betainc (x, a, b), 0, 0.4)
=> 0.13867
or following your example:
function r = f(x,y,z,theta) r = x+y+z+theta; endfunction
x = 1; y = 1; z = 1;
quad(@(theta) f(x,y,z,theta), 0, 2*pi)
ans = 38.589
Tony Richardson
kgulliks [mailto:kevin.gullikson at gmail dot com] wrote:
> Subject: Integration with parameters
>
>
> I have a function that depends on x,y,z, and theta, but I am only
> integrating
> with respect to theta. Is there a way to pass x,y, and z as parameters
> to
> the function? I would like to be able to repeatedly integrate with
> different
> values of x,y,z. For the sake of example, lets say the function is
> f(x,y,z,theta) = x+y+z+theta and I want
> 2pi
> /
> |f dtheta
> /
> 0
>
> for various values of x,y,z.