I want Solution of my program by using matlab 2008a

1 vue (au cours des 30 derniers jours)
Dr. Siva Malla
Dr. Siva Malla le 6 Déc 2012
I wrote a program to find the 3 variables from 3 equations in matlab 2008a. but its taking too much time to giving outputs and some times my system get hanging is I run this program. my system has 16GB ram. Here i posted my program with variables are VL1, L1 and ID. I used simple equations, but why matlab 2008 is taking more time to give outputs?. can anybody give alternate solution/code/commends to solve this 3 variables very quickly by using matlab 2008a.
Program:
clc
clear all
g=4;
L=1.0*1e-4;
a=0.15*1e-4;
W=100*1e-4;
q=1.6*1e-19;
NT1=4*1e15;
NT2=3*1e15;
NT3=4*1e15;
CCp1=3*1e-14;
CCn1=2*1e-14;
CCp2=1*1e-15;
CCn2=2.4*1e-15;
CCp3=1*1e-15;
CCn3=5*1e-15;
Eg=3.2*q;
Ef=1.5313*q;
Et1=Eg-0.67*q;
Et2=Eg-1.65*q;
Et3=Eg-0.93*q;
Ev=0;
Es=85.845*1e-14;
K=8.62*1e-5;
T=300;
KTev=K*T;
KT=0.0259*q;
m0=9.1*1e-31;
mp=0.77*m0;
Vpth=(3*KT/mp)^0.5;
mn=0.351*m0;
Vnth=(3*KT/mn)^0.5;
mc=0.76*m0;
mv=1.2*m0;
h=6.626*1e-34;
Nc=2*((2*pi*mc*KT/h^2)^1.5)*1e-6;
Nv=2*((2*pi*mv*KT/h^2)^1.5)*1e-6;
Nd=5*1e17;
Nref=2*1e17;
Umin=40;
Umax=950;
r=0.76;
vsat=2.07*1e7;
y=(Eg/(2*KT));
ni=((Nc*Nv)^0.5)*exp(-y);
Vbi=0.8-((KT/q)*log(Nc/Nd));
U0= Umin + ((Umax - Umin)/(1+ ((Nd/Nref)^r)));
d1=0.98
Ec=(vsat/U0)*(d1/(1-d1));
Nsam=3*1e15;
Nsdp=5*1e15;
Ep1=CCp1*Vpth*Nv*exp(-((Et1-Ev)/KT));
En1=CCn1*Vnth*Nc*exp(-((Eg-Et1)/KT));
Ep2=CCp2*Vpth*Nv*exp(-((Et2-Ev)/KT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lgd));
P=solve(y)
h011=(((2*Es)/(q*Nd))*(Vsbi-VG+(VD(i)-P*Rdo)))^0.5;
h01=real(h011);
B1=((P/G0)*((Lgd/Vgd)))-a ;
B=real(B1);
K1=hlsg-h01-(B*(log(abs((B+hlsg)/(B+h01)))));
K=real(K1);
Rd1=Lgd*K/(Es*U0*W*Vgd);
Rd=Rd1;
Pr=P;
else
Ps=Pr
h011=(((2*Es)/(q*Nd))*(Vsbi-VG+(VD(i)-Ps*Rdo)))^0.5;
h01=real(h011);
B1=((P/G0)*((Lgd/Vgd)))-a
B=real(B1);
K1=hlsg-h01-(B*(log(abs((B+hlsg)/(B+h01)))));
K=real(K1);
Rd1=Lgd*K/(Es*U0*W*Vgd);
Rd=Rd1;
end
Rd=double(Rd1)
Y1=q*W*U0*vsat*(Nd-Nsubm)/(vsat*L1+U0*(VL1-ID*(Rs)));
hL1=((Vbi-VG+VL1)/Vp)^0.5;
hs=((Vbi-VG+ID*Rs)/Vp)^0.5
h1L1=((Ubi+VL1)/Vp)^0.5
h1s=((Ubi+ID*Rs)/Vp)^0.5;
eq1=VD(i)-VL1-ID*Rd-2*hL1*Ec/pi*sinh(pi*(L-L1)/(2*hL1));
eq2=ID-Y1*a*Vp*(((VL1-ID*Rs)/Vp)-2/3*(hL1^3-hs^3)-2/3*k11*(h1L1^3-h1s^3));
eq3=ID-q*(Nd-Nsubm)*W*d1*vsat*a*(1-hL1-k11*h1L1);
[ID,L1, VL1]=solve(eq1,eq2,eq3,ID,L1,VL1)
VL=VL1
end
  1 commentaire
Walter Roberson
Walter Roberson le 7 Déc 2012
Have you profiled to figure out which part is slow?
I do not have the Symbolic Toolbox, but if you can show the inputs to one of the solve() that is taking so long, I can test to see roughy how long would be expected.

Connectez-vous pour commenter.

Réponses (2)

Jan
Jan le 7 Déc 2012
  • Avoid all repeated processing inside the loop. E.g. this can be move outside the FOR loop and I guess trhis concerns a lot of other lines also:
syms Ich ID VL1 L1
Lsg=0.3*1e-4;
Lgd=0.8*1e-4;
Lg=L;
  • sqrt(x) is faster than x^0.5
  • 3.14e8 is faster than 3.14 * 1e8
  • When most of the time is spent in the solve() command, improving the shown code is irrelevant. Use tic, toc to measure this.
  • The code looks complicated, which impedes a debugging. Therefore I do not understand the sentence "I used simple equations".Any simplifications would be a good strategy. Comments do not increase the run-time, but reduce the debug time.
  • Please explain, what "but its taking too much time to giving outputs" means. Actually "too much time" might be a seconds or a month, but you get a result in both cases.
  • "why matlab 2008 is taking more time" - more time than what?

Pritesh Shah
Pritesh Shah le 7 Déc 2012
Problem because There are many place missing semi column at the end of sen stance.

Community Treasure Hunt

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

Start Hunting!

Translated by