非线性积分方程组中含变限积分fsolve数值求解报错: Limits of integration must be double or single scalars
4 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
问题描述:
待求方程组{f1=0, f2=0, f3=0}中包含变量pl以及pr,pl和pr的表达式中包含上限是变量的积分(代码中加粗部分)。在通过matlabFunction处理为匿名函数后,int被integral替代,而integral不支持变量作为上下限,故报错:
Error using integral
Limits of integration must be double or single scalars.
可能有用的参考:
https://www.zhihu.com/question/46915508
这是我找到的一个相近的问题,但是我看不懂。。。
问题代码:
++++++++++++++++++++++++++
% 参数定义部分省略
beta = atan(x1/y1);
xL = sqrt(x1^2+y1^2)*cos(pi-alph-beta);
DL = sqrt(x1^2+y1^2)*sin(pi-alph-beta);
xR = sqrt(x1^2+y1^2)*cos(beta-alph);
DR = sqrt(x1^2+y1^2)*sin(beta-alph);
LL = DL^2+(xL-x)^2;
RR = DR^2+(xR-x)^2;
pl = -12*mu_L*rho_S^4*h_m^3*Uratio^3*(Uratio*int(LL^2*x,0,x)+C*int(LL^1.5, 0,x))/(rho_L*T0^3*K_L^3)+P0;
pr = -12*mu_L*rho_S^4*h_m^3*Uratio^3*(Uratio*int(RR^2*x,0,x)+C*int(RR^1.5, 0,x))/(rho_L*T0^3*K_L^3)+P0;
% 对pl和pr进行定积分,得到目标方程组
f1 = int(pl*x,x,-L,0)+int(pr*x,x,0,L)+M/d;
f2 = int(pl,x,-L,0)*sin(alph+tilt)+int(pr,x,0,L)*sin(alph-tilt)-G/d-2*L*P_e*sin(alph)*cos(tilt);
f3 = int(pl,x,-L,0)*cos(alph+tilt)-int(pr,x,0,L)*cos(alph-tilt)+2*L*P_e*sin(alph)*sin(tilt);
% 进行求解
% 初始值猜测
initial_guess = [0.5, 0.1, 2];
% 定义求解函数
equations = matlabFunction(f1,f2,f3, 'Vars', {x1, y1, Uratio});
% 使用fsolve求解方程组
result = fsolve(@(vars) equations(vars(1), vars(2), vars(3)), initial_guess);
+++++++++++++++++++++++++++++++++
0 Commenti
Risposta accettata
Ayush
il 22 Ago 2023
Modificato: Ayush
il 22 Ago 2023
此邮件使用英语,旨在为您提供最快速的答复。如果您希望得到中文回复,请告诉我
们。我们同事会为您翻译此邮件。
As mentioned in the documentation the `integral` function does support symbolic expressions and numbers as limits of integration. This means you can use symbolic variables as limits without encountering the error mentioned earlier.
% Define the symbolic variables and expressions
syms x pl pr
pl_expr = -12*mu_L*rho_S^4*h_m^3*Uratio^3*(Uratio*integral(LL^2*x,0,x)+C*integral(LL^1.5, 0,x))/( rho_L*T0^3*K_L^3)+P0;
pr_expr = -12*mu_L*rho_S^4*h_m^3*Uratio^3*(Uratio*integral(RR^2*x,0,x)+C*integral(RR^1.5, 0,x))/( rho_L*T0^3*K_L^3)+P0;
Hence, you can use symbolic expressions as limits of integration in the `integral` function without encountering any errors.
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Symbolic Math Toolbox in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!