MATLAB: Help with code error

%Fermi Function Calculation, f(ΔE, T) % Constant k=8.617e-5; %Computation proper for ii=l: 4; T= l00*ii; kT=k*T; dE(ii,1)=-5*kT; for ij=1: 101; f(ii,jj)= 1/(1 +exp(dE(ii,jj)/kT)); dE(ii,jj+1)=dE(ii,jj)+(0.1 *kT) end end dE=dE(1:4,1 :101); %This step strips the extra dE value %plotting results close plot(dE,f);grid; xlabel(E-EF(eV)); text(0.05,0.2,'T= 400K'); text(-.03,0.1,'T=100K');

Best Answer

One problem is that this loop index should be ‘jj’, not ‘ij’:
for jj = 1 : 101
and you are using the lower-case letter ‘l’ instead of the number 1 is two places.
This runs:
k=8.617e-5;
%Computation proper
for ii= 1 : 4;
T= 100*ii;
kT=k*T;
dE(ii,1)=-5*kT;
for jj=1: 101;
f(ii,jj)= 1/(1 +exp(dE(ii,jj)/kT));
dE(ii,jj+1)=dE(ii,jj)+(0.1 *kT);
end
end
dE=dE(1:4,1 :101); %This step strips the extra dE value
plot(dE,f);grid;
xlabel('E-EF(eV)');
text(0.05,0.2,'T= 400K');
text(-.03,0.1,'T=100K');
I am not certain what result you want for the plot.
Related Question