フィルターのクリア

why " if " condition of expression is tenable , but it cant do the statement ?

1 回表示 (過去 30 日間)
Tai-i
Tai-i 2012 年 5 月 2 日
here is my code
syms E Eg V g;
c=3 .*(10.^8); % m/s
h=4.1361e-015; % eV.s
k=8.62E-5;
Tc=300;
Eg=1.48;
Ei=0.5;
Ec=Eg-Ei;
a=quad( @(E)(E.^2) ./ (exp(E./0.5172)-1), Ei , Ec)- quad(@(E)(E.^2) ./ (exp(( E-Uiv )./0.0259)-1),Ei,Ec);
b=quad( @(E)(E.^2) ./ (exp(E./0.5172)-1), Ec , Eg)-quad(@(E)(E.^2) ./ (exp(( E-Uci )./0.0259)-1),Ec,Eg);
for Uiv = 0.484:0.0001:0.485
for Uci = 0.905:0.0001:0.906
a
b
if a==b
Uiv
Uci
end
end
end
i check a and b but it doesnt give me Uiv & Uci
thx :)

採用された回答

Walter Roberson
Walter Roberson 2012 年 5 月 2 日

その他の回答 (1 件)

Venn Ravichandran
Venn Ravichandran 2012 年 5 月 2 日
Use:
if abs(a-b) <= eps
% my operations here
end
Floating point comparisons can cause such errors, since you will have small changes (~1e-10) in the numbers generated by your {for} loop.

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by