필터 지우기
필터 지우기

Partial integration

조회 수: 8 (최근 30일)
Tomislav Broni?
Tomislav Broni? 2011년 7월 10일
I have integrate twice, but IT IS NOT a double integral (which would be easy with quad2d or dblquad), but its smth like this: int(a->b)(f(x) * int(c->d)(g(x,x') dx')dx)
so basicly, i need to partialy integrate g(x,x') by x':c->d, then multiply with f(x), and integrate with x:a->b)
and after a few hours spent on this website and searching the matlab documentation and finding nothing of use, i decided to ask here. thanks for any help!
  댓글 수: 1
Bjorn Gustavsson
Bjorn Gustavsson 2011년 7월 13일
Come to think of it it actually is a double integral:
\int_a^b f(x)*\int_c^d g(x,x')dx' dx = \int_a^b \int_c^d f(x)*g(x,x')dx' dx

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

채택된 답변

Tomislav Broni?
Tomislav Broni? 2011년 7월 12일
I solved the error by dividing the calculations up into 4 integrals, for each cell of the matrix. this is needed becouse quadgk calculates with an array of values (about 150), which was incompatible with the 2×1 and 1×2 and 2×2 matrices. so I calculated each of the 4 cells, and put them back together. your example works, but only becouse the functions you inserted in quadgk were 1×1, try putting a 2×2 matrix in there!
  댓글 수: 1
Bjorn Gustavsson
Bjorn Gustavsson 2011년 7월 13일
Nowhere in your example did I see any matrices of functions, so obviously I could not guess stat you had such a problem, only that you wanted to integrate someting like this:
\int_a^b f(x)*\int_c^d g(x,x')dx' dx
So this is what I gave you.

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

추가 답변 (3개)

Tomislav Broni?
Tomislav Broni? 2011년 7월 11일
still could use some help here! and just to say up front, the function g(x,x') doesnt have a explicit integral, so just using int wont work

Bjorn Gustavsson
Bjorn Gustavsson 2011년 7월 11일
Maybe something based on this pattern would work:
g = @(x,xp) (x-xp).^2;
f = @(x) x;
IntOfG = @(x,c,d) quadgk(@(xp) g(x,xp),c,d);
res = quadgk(@(x) f(x).*IntOfG(x,c,d),a,b);

Tomislav Broni?
Tomislav Broni? 2011년 7월 11일
quadgk is giving an error each time i try this, error trace:
??? Error using ==> quadgk>finalInputChecks at 476 Supported classes are 'double' and 'single'.
Error in ==> quadgk>evalFun at 358
finalInputChecks(x,fx);
Error in ==> quadgk>f1 at 375
[y,too_close] = evalFun(tt);
Error in ==> quadgk>vadapt at 269
[fx,too_close] = f(x);
Error in ==> quadgk at 208
[q,errbnd] = vadapt(@f1,interval);
if i understand this error, he calls it becouse the return value of quadgk isnt the same type as the calling variables (expects double, but gets function handle ?)
please correct me if im wrong
  댓글 수: 1
Bjorn Gustavsson
Bjorn Gustavsson 2011년 7월 12일
Hi,
If you read the help for quadgk you see that the first argument should be a function.
Since you don't show me how f1 is defined I can't know why you get that error. If you try to test/evaluate the functions you define step by step (in my example g, f and IntOfG) you can at least make sure that they work. The only thing I can say is that my example works in matlab R2009a.

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

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by