Prev: Bitwise manipulation of data and memory issue
Next: Problems with parfor, sim and non local workers
From: Achal on 29 Jun 2010 05:14 Hi, I am working with the following code format long; clear; % T=300; % temperature % constants h=6.626068e-34; % planck's constant me=9.109e-31; % electronic mass k=1.386065e-23; % boltzmann's constant q=1.602e-19; % electronic charge na=1e+17; % acceptor concentration nd=0; % donor concentration tox=2e-7; % oxide thickness vfb=-0.9; % flat band voltage phit=k*T/q; % thermal voltage vg=0:20e-3:2; % gate voltage psis1(101)=0; % %psis2(101)=0; % %psis3(101)=0; % phib = phit*log(na/10e+10); x=0; for i=1:101 psis1(i)=fsolve(@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300),phib); %psis1(i)=fsolve(@(psi_s)surf_p_eq1(vg(i),vfb,gamma,Na,Nd),phib); %psis1(i)=fsolve(@(psi_s)surf_p_eq1(vg(i),vfb,gamma,Na,Nd),phib); end figure(1) plot(vg,psis1); func [eq1] = surf_pot_eq1(gate_v,fb_v,surf_p,n_a,n_d,t_ox,temp) h=6.626068e-34; % planck's constant me=9.109e-31; % electronic mass k=1.386065e-23; % boltzmann's constant q=1.602e-19; % electronic charge Ec=1.12; % conduction band energy Ev=0; % Valence band energy ed=45.5e-3; % Ec - Ed ea=44.39e-3; % Ea - Ea me_n=1.08*me; % electron effective mass me_p=0.56*me; % hole effective mass nc=(2*(2*pi*me_n*k*T(i))^1.5)/(h*h*h)*1e-6; % conduction band density of states nv=(2*(2*pi*me_p*k*T(i))^1.5)/(h*h*h)*1e-6; % valence band density of states Kox=3.9; % dilectric constant oxide Ks=11.7; % dilectric constant silicon eo=8.854e-14; % permittivity of free space phit = K*temp/q; % thermal voltage cox=Kox*eo/t_ox; % cap per unit area phit=k*T/q; % thermal voltage Ei=Ec/2+k*temp*3/(4*q)*log(me_p/me_n); % intrinsic fermi-level as function of temperature ef=fsolve(@(fe)fe_b(n_a,n_d,ea,ed,nc,nv,fe,temp),0);% fermi-level estimation for a particular temperature phi_b=Ei-ef; po=nv*exp((Ev-ef)/phit); gamma=sqrt(2*q*Ks*eo*po)/cox; % body effect coeficient eq1 = fb_v + surf_p + gamma*sqrt(phit*exp(-surf_p/phit) + surf_p - phit + exp(-2*phi_b/phit)*(exp(surf_p/phit) - surf_p - phit)) - gate_v; the dimensions of vector x match with the dimensions of vector phib, but I still get this error ??? Attempt to execute SCRIPT surf_pot_eq1 as a function. Error in ==> surf_p_eq_check>@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300) at 23 psis1(i)=fsolve(@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300),phib); Error in ==> fsolve at 180 fuser = feval(funfcn{3},x,varargin{:}); Error in ==> surf_p_eq_check at 23 psis1(i)=fsolve(@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300),phib); any kind of help will be really appreciated Thanks Achal ellieandrogerxyzzy(a)mindspring.com.invalid (Roger Stafford) wrote in message <ellieandrogerxyzzy-0902061139470001(a)pool1459.cvx3-bradley.dialup.earthlink.net>... > In article <ef28597.0(a)webx.raydaftYaTP>, gsboris <gsboris(a)yahoo.com> wrote: > > > gsboris wrote: > > > > > > > > > while solving set of nonlinear equations "index out of bounds > > > numel(x)=2" shows up if I have more then 2 equations > > Even set of > 2 linear equations gives that error > > > > function file: > > function F = myfun(x) > > F = [x(1) - x(2) + x(3); > > 2*x(1) - x(2) + x(3); > > 12*x(1) - x(3) + 20*x(3)]; > > > > file calling for set of equations to solve it using fsolve: > > options=optimset('Display','iter'); > > [x,fval] = fsolve(@myfun,x0,options); > > return: > > ??? Attempted to access x(3); index out of bounds because numel(x)=2. > > Error in ==> myfun at 3 > > F = [x(1) - x(2) + x(3); > > Error in ==> fsolve at 180 > > fuser = feval(funfcn{3},x,varargin{:}); > > Error in ==> mytry at 8 > > [x,fval] = fsolve(@myfun,x0,options); > > > > Any help out there? > ----------------- > It looks as though you have called on 'fsolve' with the variable, 'x0', > not set to a vector with three elements. 'x0' is supposed to be the > vector that 'fsolve' starts with in its search for a solution and it > should be the same size as the vector 'myfun' uses as input. > > Your 'myfun' looks to me like a set of homogeneous linear equations > whose only solution would be x = 0. Is that what you intended? > > (Remove "xyzzy" and ".invalid" to send me email.) > Roger Stafford
From: Achal on 29 Jun 2010 05:24 Hi, I am working with the following code format long; clear; % T=300; % temperature % constants h=6.626068e-34; % planck's constant me=9.109e-31; % electronic mass k=1.386065e-23; % boltzmann's constant q=1.602e-19; % electronic charge na=1e+17; % acceptor concentration nd=0; % donor concentration tox=2e-7; % oxide thickness vfb=-0.9; % flat band voltage phit=k*T/q; % thermal voltage vg=0:20e-3:2; % gate voltage psis1(101)=0; % %psis2(101)=0; % %psis3(101)=0; % phib = phit*log(na/10e+10); x=0; for i=1:101 psis1(i)=fsolve(@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300),phib); %psis1(i)=fsolve(@(psi_s)surf_p_eq1(vg(i),vfb,gamma,Na,Nd),phib); %psis1(i)=fsolve(@(psi_s)surf_p_eq1(vg(i),vfb,gamma,Na,Nd),phib); end figure(1) plot(vg,psis1); func [eq1] = surf_pot_eq1(gate_v,fb_v,surf_p,n_a,n_d,t_ox,temp) h=6.626068e-34; % planck's constant me=9.109e-31; % electronic mass k=1.386065e-23; % boltzmann's constant q=1.602e-19; % electronic charge Ec=1.12; % conduction band energy Ev=0; % Valence band energy ed=45.5e-3; % Ec - Ed ea=44.39e-3; % Ea - Ea me_n=1.08*me; % electron effective mass me_p=0.56*me; % hole effective mass nc=(2*(2*pi*me_n*k*T(i))^1.5)/(h*h*h)*1e-6; % conduction band density of states nv=(2*(2*pi*me_p*k*T(i))^1.5)/(h*h*h)*1e-6; % valence band density of states Kox=3.9; % dilectric constant oxide Ks=11.7; % dilectric constant silicon eo=8.854e-14; % permittivity of free space phit = K*temp/q; % thermal voltage cox=Kox*eo/t_ox; % cap per unit area phit=k*T/q; % thermal voltage Ei=Ec/2+k*temp*3/(4*q)*log(me_p/me_n); % intrinsic fermi-level as function of temperature ef=fsolve(@(fe)fe_b(n_a,n_d,ea,ed,nc,nv,fe,temp),0);% fermi-level estimation for a particular temperature phi_b=Ei-ef; po=nv*exp((Ev-ef)/phit); gamma=sqrt(2*q*Ks*eo*po)/cox; % body effect coeficient eq1 = fb_v + surf_p + gamma*sqrt(phit*exp(-surf_p/phit) + surf_p - phit + exp(-2*phi_b/phit)*(exp(surf_p/phit) - surf_p - phit)) - gate_v; the dimensions of vector x match with the dimensions of vector phib, but I still get this error ??? Attempt to execute SCRIPT surf_pot_eq1 as a function. Error in ==> surf_p_eq_check>@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300) at 23 psis1(i)=fsolve(@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300),phib); Error in ==> fsolve at 180 fuser = feval(funfcn{3},x,varargin{:}); Error in ==> surf_p_eq_check at 23 psis1(i)=fsolve(@(x)surf_pot_eq1(vg(i),vfb,x,na,nd,tox,300),phib); any kind of help will be really appreciated Thanks Achal ellieandrogerxyzzy(a)mindspring.com.invalid (Roger Stafford) wrote in message <ellieandrogerxyzzy-0902061139470001(a)pool1459.cvx3-bradley.dialup.earthlink.net>... > In article <ef28597.0(a)webx.raydaftYaTP>, gsboris <gsboris(a)yahoo.com> wrote: > > > gsboris wrote: > > > > > > > > > while solving set of nonlinear equations "index out of bounds > > > numel(x)=2" shows up if I have more then 2 equations > > Even set of > 2 linear equations gives that error > > > > function file: > > function F = myfun(x) > > F = [x(1) - x(2) + x(3); > > 2*x(1) - x(2) + x(3); > > 12*x(1) - x(3) + 20*x(3)]; > > > > file calling for set of equations to solve it using fsolve: > > options=optimset('Display','iter'); > > [x,fval] = fsolve(@myfun,x0,options); > > return: > > ??? Attempted to access x(3); index out of bounds because numel(x)=2. > > Error in ==> myfun at 3 > > F = [x(1) - x(2) + x(3); > > Error in ==> fsolve at 180 > > fuser = feval(funfcn{3},x,varargin{:}); > > Error in ==> mytry at 8 > > [x,fval] = fsolve(@myfun,x0,options); > > > > Any help out there? > ----------------- > It looks as though you have called on 'fsolve' with the variable, 'x0', > not set to a vector with three elements. 'x0' is supposed to be the > vector that 'fsolve' starts with in its search for a solution and it > should be the same size as the vector 'myfun' uses as input. > > Your 'myfun' looks to me like a set of homogeneous linear equations > whose only solution would be x = 0. Is that what you intended? > > (Remove "xyzzy" and ".invalid" to send me email.) > Roger Stafford
From: Achal on 29 Jun 2010 05:42 I think I figured the problem with the code function was not properly defined. Issue with the syntax in defining the function. Regards Achal
|
Pages: 1 Prev: Bitwise manipulation of data and memory issue Next: Problems with parfor, sim and non local workers |