numerically integrate multidimensional function along one dimension.

10 ビュー (過去 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 Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by