请教求二元函数的积分​“积分范围必须为双精​度或单精度标量”处理​方法

请教大佬,准备对下式求积分,其中变量是r和h,fR1是对h进行积分得到一个r的函数,再对fR1积分
但是一直报错:错误使用 integral,积分范围必须为双精度或单精度标量。我尝试了很多方法,但是一直不对,想请教一下问题出在哪里呢?该如何修改,或者有什么更好的办法求出这个积分值,感谢指点。
代码如下:
f1=@(r,h)-hmax*hmin-2*h.^2+4*h.^3+(hmax*hmin./h.^2-2*h)*r.^2;
fR1=@(r)(6.*r/(radius^2*(hmax-hmin)^3)).*integral(@(h)Px2(sqrt(r.^2-h.^2)).*f1(r,h),sqrt(r.^2-4*disth.^2),sqrt(r.^2-disth.^2));
integral(fR1,0,3);
注:如果将fR1中integral的积分上下限变为两个常量就不会报错,但积分上下限是和r有关的变量,这个问题怎么解决呢
注:积分中Px2是简单的求法,应该改成Px,Px代码如下
function y=Px(xt)
disth=50;
lambdawurenji=20;
Kgang=lambdawurenji*pi*disth^2;
if xt > 0 & xt<disth
y=0;
end
if xt >= disth & xt < (2*disth)
y=(2/(lambdawurenji*vx(xt)-Kgang))*((Kgang*(1-exp(-lambdawurenji*vx(xt))))/(lambdawurenji*vx(xt)*(1-exp(-Kgang))));
end
if xt >= (2*disth)
y=(1-exp(-Kgang))/Kgang;
end
end
求大佬解答一下如果fR的积分中Px2改为Px应该怎么解决

2 comentarios

Dyuman Joshi
Dyuman Joshi el 7 de Dic. de 2023
What you want to do is symbolic integration, which can not be performed with numerical integration functions (integral in this case).
You will need to use symbolic integration tools for that, which requires the Symbolic Math Toolbox.
See -
zhifei
zhifei el 11 de Dic. de 2023
Editada: zhifei el 11 de Dic. de 2023
Your advice was effective. Thank you for your kindly help.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Symbolic Math Toolbox en Centro de ayuda y File Exchange.

Preguntada:

el 6 de Dic. de 2023

Editada:

el 11 de Dic. de 2023

Community Treasure Hunt

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

Start Hunting!