You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MATLAB integral函数报错:A和B必须为浮点标量求助

积分报错问题:A and B must be floating-point scalars

报错信息如下:

Error using integral (line 85)
A and B must be floating-point scalars.

Error in integrantK_sup (line 6)
I=integral(F1,double(ALPHA*R_int_ind),double(ALPHA*R_ext_ind)); % équation (70), p.2834

Error in Script_A_MH_L (line 228)
    integ=integrantK_sup(ALPHA);
所用代码

主脚本代码

nb_pt_v=200;  pas_v=Ep_plaque/nb_pt_v;
nb_pt_h=200;  pas_h=3*R_ext_ind/nb_pt_h;
ik=1:nb_pt_h+1;
il=1:nb_pt_v+1;
r=  0    + (ik-1).*pas_h;        
z=  0    - (il-1).*pas_v;        [r,z]=meshgrid(r,z);
A=zeros(nb_pt_v+1,nb_pt_h+1);

pas_alpha=10;
nb_pas_al=1500;
for ALPHA=0.1:pas_alpha:nb_pas_al
    integ=integrantK_sup(ALPHA);
    A=integ.*pas_alpha+A;
end

积分函数integrantK_sup定义

function integ=integrantK_sup(ALPHA)
% équation (74), p.2835
global   r z R_int_ind R_ext_ind Ep_plaque Ep_ind Airgap w mur sigma_plaque  
F1=@(x)x.*besselj(1,x);
I=integral(F1,double(ALPHA*R_int_ind),double(ALPHA*R_ext_ind)); % équation (70), p.2834
Alpha_1=sqrt(ALPHA^2+1j*w*mur*sigma_plaque);

aa=I.*besselj(1,ALPHA.*r).*(exp(-ALPHA*Airgap)-exp(-ALPHA*(Airgap+Ep_ind)));
bb=(ALPHA*Alpha_1*exp(2*Alpha_1*Ep_plaque).*exp(Alpha_1.*z));
cc=ALPHA*Alpha_1.*exp(-Alpha_1.*z);
dd=((ALPHA-Alpha_1)*Alpha_1+Alpha_1*(ALPHA+Alpha_1)*exp(2*Alpha_1*Ep_plaque));

integ=((1/(ALPHA^3)).*aa).*((bb+cc)/dd);

end

参数初始化代码

Ep_plaque = 5e-3;
R_plaque = 20e-2;    
R_int_ind   = 5e-2;
R_ext_ind   = 15e-2;
Ep_ind      = 2e-3;
Airgap      = 2e-3;     
R_air = 5*R_plaque;
H_air = 100*Ep_plaque;
mu0=4*pi*1e-7;          %% Perméabilité magnétique du vide 
nu0=1/mu0;              %% Réluctivité magnétique du vide
mur=1e5;                %% Perméabilité magnétique relative 
nur=1.0/mur;            %% Perméabilité magnétique du circuit magnétique
Js=5e6;                 %% Densité de courant source
Is = Js *((R_ext_ind-R_int_ind)*Ep_ind); %% courant source 
ADirichlet=0;           %% Valeurs Dirichlet du potentiel vecteur magnétique 
sigma_plaque=1e6;       %% Conductivité électrique du circuit magnétique
fr=50000;               %% Fréquence de travail
w = 2*pi*fr ;           %% Pulsation 
问题定位

报错根源在于调用integral函数计算F1积分时,传入的上下限ALPHA * R_int_ind和ALPHA * R_ext_ind不符合要求——integral要求积分上下限必须是浮点型标量,当前代码中存在上下限不满足该条件的情况。

内容的提问来源于stack exchange,提问作者hakim

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 05:50:23