%Chapt3Exercise7.m
%numerical solution to Schroedinger equation for
%rectangular potential well with infinite barrier energy
clear
clf;

length = 10;							%length of well (nm)
npoints=200;							%number of sample points
x=0:length/npoints:length;				%position of sample points
mass=0.07;								%effective electron mass
num_sol=4;								%number of solutions sought

for i=1:npoints+1; v(i)=0; end			%potential (eV)

[energy,phi]=Solve_schM(length,npoints,v,mass,num_sol);	%call solve_schM

%energy eigenvalues  
 for i=1:num_sol
 sprintf(['eigenenergy (',num2str(i),') = ',num2str(energy(i)),' eV'])	
 end
     
figure(1);
 plot(x,v,'b');xlabel('Position, x (nm)'),ylabel('Potential energy, (eV)');
 ttl=['Chapt3Exercise7, m* = ',num2str(mass),...
     'm_0, Length = ',num2str(length),'nm'];
 title(ttl);

s=char('y','k','r','g','b','m','c');%plot curves in different colors

figure(2);
for i=1:num_sol
   j=1+mod(i,7);
     plot(x,phi(:,i),s(j));			%plot eigenfunctions
     hold on;
  end
 xlabel('Position, x (nm)'),ylabel('Wave function, \psi(x)');
 title(ttl);
hold off;