quadgk errors: Supported classes are 'double' and 'single'

Hi all,
Could somebody be so kind to help me with quadgk errors as following:
> > ??? Error using ==>quadgk/finalInputChecks (line 447) > > Supported classes are 'double' and 'single'.
> > > Error in ==> quadgk/evalFun (line 331) finalInputChecks(x,fx);
> > > quadgk/f1 (line 348) [y,too_close] = evalFun(tt);
> > > Error in ==> quadgk/vadapt (line 249) [fx,too_close] = f(x);
> > > quadgk (line 188) [q,errbnd] = vadapt(@f1,interval);
Here are the codes:
clear all
syms z
kB=1.38e-23;
Eg=2.18.*(1.6e-19);
T=300;
TkB =4.14e-21;
hbar=1.055e-34;
me=9.11e-31; mestar=0.21.*me; N=0; EF=-3*(1.6e-19);
no=4e26;
Delta=inf;
kWN= hbar^(-1).*sqrt(me.*(Eg.*me+ Eg.*mestar-sqrt(Eg.^2.*me.^2+2*Eg.^2.*me.*mestar+Eg.^2.*mestar.^2+4*TkB.*z.*Eg.*me.*mestar)+2*TkB.*mestar.*z)./mestar);
FF=@(z)(kWN.^3).*exp(z-EF./TkB).*(exp(z-EF./TkB)+1).^(-2)
while Delta>=0.005 & N<=100
EF=(-2+0.1*N)*(1.6e-19)
nn=quadgk(FF,0,inf)
n=(1/(3*pi.^2)).*nn
N=N+1
Delta=abs((n-no)/no)
end
EF=EF/(1.6e-19)
if N>=50
disp('More than 100 terms are needed')
else
fprintf('Fermi level is: %eV',EF)
end

 Réponse acceptée

kB=1.38e-23;
Eg=2.18.*(1.6e-19);
T=300;
TkB =4.14e-21;
hbar=1.055e-34;
me=9.11e-31;
mestar=0.21.*me;
N=0;
EF=-3*(1.6e-19);
no=4e26;
Delta=inf;
kWN= @(z)hbar^(-1).*sqrt(me.*(Eg.*me+ Eg.*mestar-sqrt(Eg.^2.*me.^2+2*Eg.^2.*me.*mestar+Eg.^2.*mestar.^2+4*TkB.*z.*Eg.*me.*mestar)+2*TkB.*mestar.*z)./mestar);
while Delta>=0.005 & N<=100
EF=(-2+0.1*N)*(1.6e-19)
FF=@(z)(kWN(z).^3).*exp(z-EF./TkB).*(exp(z-EF./TkB)+1).^(-2)
nn=quadgk(FF,0,inf)
n=(1/(3*pi.^2)).*nn
N=N+1
Delta=abs((n-no)/no)
end
Best wishes
Torsten.

Plus de réponses (1)

Junning Gao
Junning Gao le 16 Août 2018

0 votes

Thanks so much, Torsten! It works! I have been struggling with this issue for quite some time!

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Produits

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by