numerical integration

Hi all
I want to numerically integral a function with four variable(f(x,y,z,v)).how can I use dblquad?

4 件のコメント

Andrew Newell
Andrew Newell 2011 年 5 月 15 日
How many variables do you want to integrate over?
rahman
rahman 2011 年 5 月 15 日
I want to integral over all of variables
Andrew Newell
Andrew Newell 2011 年 5 月 15 日
Are your integral limits rectangular? e.g., xmin <= x <= xmax?
rahman
rahman 2011 年 5 月 15 日
yes.all of four variables integration domain are limited.

サインインしてコメントする。

 採用された回答

Andrew Newell
Andrew Newell 2011 年 5 月 15 日

0 投票

This turned out to be surprisingly tricky, but here is the solution. First, define a function
function fzv = integrateOverSecondPair(fun,x,y,zmin,zmax,vmin,vmax)
% DBLQUAD evaluates FUN for a vector x and scalar y. The backwards loop is
% Matt Fig's dynamic preallocation.
for ii=numel(x):-1:1
g = @(z,v) fun(x(ii),y,z,v);
fzv(ii) = dblquad(g,zmin,zmax,vmin,vmax);
end
Then use the commands
fzv = @(x,y) integrateOverSecondPair(@f,x,y,zmin,zmax,vmin,vmax);
fxyzv = dblquad(fzv,xmin,xmax,ymin,ymax);

1 件のコメント

rahman
rahman 2011 年 5 月 15 日
tnx Andrew
That work excellent! ;)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Community Treasure Hunt

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

Start Hunting!

Translated by