How to perform 4D integral in matlab ?

조회 수: 21 (최근 30일)
Yu-Chen
Yu-Chen 2013년 5월 31일
I want to calculate the integral of a bidirectional reflectance distribution function(a function with 2 direction parameters both represent by a pair of theta and phi, so it's a 4D function). Since the function is usually not easy to factor out as multiplication of lower dimensional function it's hard to use command such as "integral" or "integral2", any suggestion about this issue ?

채택된 답변

Mike Hosea
Mike Hosea 2013년 6월 1일
The easiest way to integrate f(x,y,z,w) from a <= x <= b, c <= y <= d, e <= z <= g, and h <= w <= i is
Q = integral(@(x)integral3(@(y,z,w)f(x,y,z,w),c,d,e,g,h,i),a,b,'ArrayValued',true);
if the limits are functions of the preceding variables, i.e.:
c(x), d(x), e(x,y), g(x,y), h(x,y,z), i(x,y,z)
you will have to fix x in them as we did for the integrand:
Q = integral(@(x)integral3(@(y,z,w)f(x,y,z,w),c(x),d(x),@(y)e(x,y),@(y)g(x,y),@(y,z)h(x,y,z),@(y,z)i(x,y,z)),a,b,'ArrayValued',true);
The other, and perhaps faster way in some cases, would be to do an integral2(integral2(...)...) nesting, but this requires a bit of work to set up because of the vectorization that integral2 requires of the integrand.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Install Products에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by