numerically integrate multidimensional function along one dimension.

조회 수: 2 (최근 30일)
sasha
sasha 2014년 11월 11일
편집: Mike Hosea 2014년 11월 13일
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
Torsten
Torsten 2014년 11월 12일
How is f given ? By an explicit equation for f depending on x, y and z ?
Best wishes
Torsten.

댓글을 달려면 로그인하십시오.

답변 (2개)

Charles
Charles 2014년 11월 11일
편집: Charles 2014년 11월 12일
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 2014년 11월 13일
편집: Mike Hosea 2014년 11월 13일
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);

카테고리

Help CenterFile Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by