Integrating a function with nested functions

조회 수: 6 (최근 30일)
TheBestTreeInTheForest
TheBestTreeInTheForest 2015년 4월 21일
Hello all,
I have been stuck on a problem where I had written a function and integrated it in regards to 1 variable and it worked fine. I then adjusted it to become a function of 2 variables and changed to a double integral. However, this isn't working properly.
The original function was:
*function s_avg=siev_avg(rs,Mw,Jv)
rp=0;
fun1=@(rp)sieving(rs,rp,Mw,Jv).*log_normal(rp).*rp.^4;
fun2=@(rp)log_normal(rp).*rp.^4;
s_avg =integral(fun1,1.03*rs,inf)/integral(fun2,0,inf);
end*
I then changed it to this:
*function Sa=actual(rs,Mw)
b=0.03648*10^9;
fun1=@(r,rp)sieving3(rs,rp,Mw,r).*log_normal(rp).*rp.^4;
fun2=@(rp)log_normal(rp).*rp.^4;
Sa =integral2(fun1,0,b,1.03*rs,inf)./integral(fun2,0,inf);
end*
And the result was that instead of the integration running on the nested function I simply get the result from before multiplied by "b" which is the maximum value of "r".
How can I get this to run the integral on the innermost function because there is basically only one function nested 3 or 4 layers deep that is actually a function of "r".
Any input would be appreciated.
Thanks.

답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by