Integrating a function with nested functions

3 次查看(过去 30 天)
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