フィルターのクリア

how solve this problem in code execution

1 回表示 (過去 30 日間)
Wael Atiyah
Wael Atiyah 2023 年 1 月 16 日
編集済み: Luca Ferro 2023 年 1 月 16 日
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

採用された回答

Luca Ferro
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 件)

カテゴリ

Help Center および File ExchangeConversion Between Symbolic and Numeric についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by