numerically integrate multidimensional function along one dimension.

1 Ansicht (letzte 30 Tage)
sasha
sasha am 11 Nov. 2014
Bearbeitet: Mike Hosea am 13 Nov. 2014
I have a function: f(x,y,z). I want to numerically integrate this function along x and be left with a function of only y and z. I can't seem to figure out how to do this. Any help would be appreciated.
Thanks
  1 Kommentar
Torsten
Torsten am 12 Nov. 2014
How is f given ? By an explicit equation for f depending on x, y and z ?
Best wishes
Torsten.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Charles
Charles am 11 Nov. 2014
Bearbeitet: Charles am 12 Nov. 2014
Integrate how?
Do you have a function of x,y,z or is time also a variable?
Also, how would this eliminate x? The integral of (x) is (1/2)*(x^2) + x(0) ... not only do you NOT get rid of x, you in fact get a higher order of x.
Are you sure you aren't looking for a partial derivative? Or do you just want to set x = some constant and have the function of f(y,z) along that particular value?
Integrating or taking a derivative will not leave you with the same function.

Mike Hosea
Mike Hosea am 13 Nov. 2014
Bearbeitet: Mike Hosea am 13 Nov. 2014
I will assume here that your function f(x,y,z) is written so that x, y, and z can be any size (vectors, matrices, N-D, whatever) and f(x,y,z) will be computed "element-wise". If this isn't the case, you can use arrayfun to build it up
fnew = @(x,y,z)arrayfun(f,x,y,z);
You should try your function on some array inputs if this is not clear, e.g. evaluate f([1,2,3],[4,5,6],[7,8,9]). The result should match [f(1,4,7),f(2,5,8),f(3,6,9)].
Now define a function of y and z where y and z are assumed to be scalars :
fyz_scalar = @(y,z)integral(@(x)f(x,y*ones(size(x)),z*ones(size(x)),xmin,xmax);
Now "vectorize" the function so that y and z can be arrays of any size (as long as they are the same size).
fyz = @(y,z)arrayfun(fyz_scalar,y,z);

Kategorien

Mehr zu Parallel Computing finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by