how solve this problem in code execution
1 次查看(过去 30 天)
显示 更早的评论
i have error in the following program
function dMt = fcn(dB,B,H, M, dH)
if dB~=0;
deltaB =1
k1=0.011;
k2=0.49;
mui0=4*pi*10e-07;
psi=30;
Ms=1.22e06;
alpha=5e-4;
L=3;
a=200;
c=0.6;
syms theta E1 E2 Ms theta
% theta=30;
Kan=4.03e4;
He=H+alpha*M;
p=k1*dB+deltaB*k2*abs(sqrt(dB));
E1=(He/a)*cos(theta)-(Kan/Ms*mui0*a)*sin(psi-theta)*sin(psi-theta);
E2=(He/a)*cos(theta)-(Kan/Ms*mui0*a)*sin(psi+theta)*sin(psi+theta);
% E1 = sym('E1');
% E2 = sym('E2');
% Ms = sym('Ms');
f1 = sin(theta)*cos(theta)*exp(E1 + E2);
f2 = sin(theta)*exp(E1 + E2);
Man = Ms * int(f1, 0, pi) / int(f2, 0, pi);
dMan=(Ms/a)*(1-coth(He/a)*coth(He/a)+(a/He)^2);
Mirr=(M-c*Man)/(1-c);
if((Man-Mirr)*dB)<0
dM=((c/mui0)*dMan)/(1-c*(alpha-1)*dMan);
else dM=(M-Man-(k*deltaB*c/(1-c))*(dMan)+p)/(mui0*(alpha-1)*(Man-M+(k*deltaB*c/(1-c))*(dMan)-(mui0*k*deltaB/(1-c))));
end
end
dMt =dM*dB;
Conversion to logical from sym is not possible.
Error in fcn (line 29)
if((Man-Mirr)*dB)<0
any one can help
0 个评论
采纳的回答
Luca Ferro
2023-1-16
编辑:Luca Ferro
2023-1-16
you declared Ms on line 8 as:
Ms=1.22e06;
but then on line on line 13 you syms it
syms theta E1 E2 Ms theta
so this 3 assignments are considering Ms as syms, not 1.22e06
Man = Ms * int(f1, 0, pi) / int(f2, 0, pi);
dMan=(Ms/a)*(1-coth(He/a)*coth(He/a)+(a/He)^2);
Mirr=(M-c*Man)/(1-c);
since both Man and Mirr depend on the never solved syms Ms, this conditional expression cannot be evaluated
if((Man-Mirr)*dB)<0
Just decide which definition of Ms you want, and if you choose to keep the syms, solve it before using it in the conditional statement.
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!