XMAX must be a floating point scalar in double integral. Kindly help.

1 vue (au cours des 30 derniers jours)
CODE:
x=0
y=0
u0=4*pi*(10^-7);
f=5*10^6;
w=2*pi*f;
u=4*pi*(10^-7);
U=2;
a=0.5
N=5
for d=0.1:0.1:1
s=0.001
N=5
wd=0.011
r0=0.0001608
e=7*(8.854*10^-12) %dry sand check again
sig=0.11 %variable so check again
alpha=3.9*10^-3 %temp coeff
T=26 %soil temp
T0=33 %room temp
dout=2*a
d1=sqrt(2)*a
aw=wd./2
din=dout-(2*N*wd)-(2*(N-2)*s)
davg=(dout-din)./(dout+din)
ltc=4.*N.*(dout-(N-1).*(wd+s)) %ORIGINAL CORRECT
Aw=pi.*(aw.^2)
R=(r0.*ltc.*(1+alpha.*(T-T0)))./Aw
theta=90
J=2.*sin(theta).*sin(theta)+cos(theta).*cos(theta)
sd=(w.*(sqrt((u.*e./2).*(sqrt(1+(sig./(w.*e))^2)-1))))^(-1)
G=exp(-d./sd)
Mt1=0
Bz=@(ai) (((u)/(2*pi*sqrt(((r0+ai)^2)+(d^2))))*((ellipticK(pi/2))+(((-r0^2-d^2+ai^2)/((r0-ai)^2+d^2))*ellipticE(pi/2))))
M=zeros(1,N*N)
for i=1:1:N
ai=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s
for j=1:1:N
aj=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s
M=integral2(Bz,0,ai,0,aj)
end
end
Mt1=Mt1+M
Mtotal=Mtl*J*G
end
end
ERROR:
Error using integral2 (line 76)
XMAX must be a floating point scalar.
Error in FPSCCLM2 (line 93)
M=integral2(Bz,0,ai,0,aj)

Réponse acceptée

Walter Roberson
Walter Roberson le 23 Août 2019
ai=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s
Notice the colon operators. Your ai is going to be a vector. Likewise your aj is going to be a vector.
M=integral2(Bz,0,ai,0,aj)
You are trying to use integral2() passing in a vector of maximum x values in the variable ai, and a vector of maximum y values in the variable aj . integral2() must have scalar numeric upper and lower bounds for x (the 0,ai parameters you pass.) For the y bounds, the 0,aj that you pass, the values can be either numeric scalars or else a function handle to a function of a single variable that passes in the current x value and permits calculating the y bound in terms of x.
Note by the way that if the call worked, then you would be overwriting all of M each iteration, so M would end up being a scalar afterwards.

Plus de réponses (0)

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by