MATLAB: Fourier Coefficient Plots with variable n or m

fourier coefficient plot

I'm trying to plot Dsf w.r.t n for a particular m or vice versa code is attached with this How can I get the Plot of Dsf w.r.t n ,for a fix m Also,Dsf w.r.t m,for a fix n
clc
%--------Define Constants all are in MKS-------%
q=1.602e-19;
h=8.85e-12;
Eox=3.9*h;
Esi=11.8*h;
Ni=1e16;
Na=1e16;
Vgs=0;
L=35e-9;
tox=3e-9;
tsi=10e-9;
y=tox;
Vds=1;
Q=-q*Na;
V=Vgs;
t1=0.0259;%thermal voltage in V%
Vbi=0.55;%source side potential%
d1=0;
phi2=0;
for n=1:1:500
kn=n*pi/L;
X1=((cosh(kn*(tox+tsi-y)))+(cosh(kn*(tox-y))))/(sinh(kn*tsi));
d2=L*(V*(1-(-1)^n))/((cosh(kn*tox))*pi*n);
d4=1/(kn*Esi*tanh(kn*tsi))+1/(kn*Esi*sinh(kn*tsi))+tanh(kn*tox)/(kn*Eox) ;
d3=(((Vbi*(1-(-1)^n))/kn+(Vds*(-1)^(n+1))/kn+(Q*((1-(-1)^n)))/(Esi*kn*kn*kn)));
for m=1:1:100
k1=(2*m-1)*pi/(2*tox);
A1=V/k1+(sin(k1*tox)*(Vbi-Vgs))/(k1^2);
A2=V/k1+(sin(k1*tox)*(Vbi+Vds-Vgs))/(k1^2);
d1=d1+(2*(sin(k1*(tox)))*kn*(A1+A2*((-1)^(n+1)))/(tox*(kn^2+k1^2)));
end
Dsf=((d1+d2-d3))/(kn*d4);
end
plot(n,Dsf, 'r')
d1
Dsf
end

Best Answer

%--------Define Constants all are in MKS-------%
q=1.602e-19;
h=8.85e-12;
Eox=3.9*h;
Esi=11.8*h;
Ni=1e16;
Na=1e16;
Vgs=0;
L=35e-9;
tox=3e-9;
tsi=10e-9;
y=tox;
Vds=1;
Q=-q*Na;
V=Vgs;
t1=0.0259;%thermal voltage in V%
Vbi=0.55;%source side potential%
d1=0;
phi2=0;
nvals = 1:500;
for n=nvals
kn=n*pi/L;
X1=((cosh(kn*(tox+tsi-y)))+(cosh(kn*(tox-y))))/(sinh(kn*tsi));
d2=L*(V*(1-(-1)^n))/((cosh(kn*tox))*pi*n);
d4=1/(kn*Esi*tanh(kn*tsi))+1/(kn*Esi*sinh(kn*tsi))+tanh(kn*tox)/(kn*Eox) ;
d3=(((Vbi*(1-(-1)^n))/kn+(Vds*(-1)^(n+1))/kn+(Q*((1-(-1)^n)))/(Esi*kn*kn*kn)));
for m=1:1:100
k1=(2*m-1)*pi/(2*tox);
A1=V/k1+(sin(k1*tox)*(Vbi-Vgs))/(k1^2);
A2=V/k1+(sin(k1*tox)*(Vbi+Vds-Vgs))/(k1^2);
d1=d1+(2*(sin(k1*(tox)))*kn*(A1+A2*((-1)^(n+1)))/(tox*(kn^2+k1^2)));
end
Dsf(n)=((d1+d2-d3))/(kn*d4);
end
plot(nvals,Dsf, 'r')