MATLAB Answers

XMIN must be a floating point scalar. Kindly help me in clearing the error.

5 ビュー (過去 30 日間)
Swathi S
Swathi S 2019 年 9 月 10 日
回答済み: Steven Lord 2019 年 10 月 10 日
CODE:
%all variables are declared
Mt1=0
for ai=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s
for aj=a-2*(N-1)*wd-2*(N-1)*s:2*(wd+s):a-2*(N-N)*wd-2*(N-N)*s
k=(sqrt((4*ai*row)/((row.^2)+(d.^2)+(ai.^2)+(2*ai*row))))
Bz=@(y,x)(((u0./(2.*pi))*(1./((sqrt((row+ai)).^2+(d.^2)))).*(ellipticK(k)+(((ai.^2)-(row.^2)-(d.^2))./(((row-ai).^2)+(d.^2))).*ellipticE(k))))
yl=@(x) sqrt(aj^2-x^2)
M=integral2(Bz(x,y),-yl(x), yl(x), -aj, aj)
Mt1=Mt1+M
hold on
end
end
ERROR:
XMIN must be a floating point scalar.
XMIN must be a floating point scalar.
Error in FPSSCFINAL10Sep192 (line 108)
M=integral2(Bz(x,y),-yl(x), yl(x), -aj, aj)

  2 件のコメント

Naveen Venkata Krishnan
Naveen Venkata Krishnan 2019 年 10 月 10 日
If possible attach the code .
Fabio Freschi
Fabio Freschi 2019 年 10 月 10 日
a, wd and s are missing

Sign in to comment.

回答 (1 件)

Steven Lord
Steven Lord 2019 年 10 月 10 日
Bz=@(y,x) <lengthy expression that doesn't depend on x OR y snipped>
yl=@(x) sqrt(aj^2-x^2)
M=integral2(Bz(x,y),-yl(x), yl(x), -aj, aj)
You're trying to evaluate the anonymous functions Bz and yl at some point or points and passing the numbers that are the results of those evaluations into integral2. Instead you're going to need to pass the anonymous functions themselves into integral2. That way integral2 can evaluate your functions at points of its choosing, not ones you've chosen for it.
Bz=@(y,x) <lengthy expression that doesn't depend on x OR y snipped>
yl=@(x) sqrt(aj^2-x^2);
minusyl = @(x) -yl(x);
M=integral2(Bz, minusyl, yl, -aj, aj)
Note too that integral2 is going to call your function with x and y coordinates, not y and x, so you'll need to either swap the order of inputs to Bz or add an adapter, much like I did to compute -yl(x), and pass the adapter in.
One additional flag, now that I go back and check: your Bz function doesn't actually depend on x or y. So effectively you're integrating a constant. If that's not your intention, you probably want to reexamine your derivation or original problem statement of Bz to determine how it should depend on x and/or y.

  0 件のコメント

Sign in to comment.


Translated by