%This is an example program to introduce matlab

%First make a vector of the energies you want to study
%For example energies from 0 to 3, with spacing 0.01.
Evec=0:.1:3; %Because of the semicolon you do not have to
           %see the vector.

%Now make a loop over this energy-vector

for nE=1:length(Evec)
     E=Evec(nE)
     %At each energy we may want to define some matrices
     M=[E 1; 1 -E]
     k=sqrt(E-2);
     N=[1 1; i*k -i*k]
     %and calculate som matrix products
     P=M*N;
     % Maybe we want to use some element of P
     % to calculate something
     p11=P(1,1);
     p12=P(1,2);
     x=p11*p12;
     %Of course we can store this result in a vector
     Xvec(nE)=x;
end

%Now when the loop is finished we have the x-values
%for all energies in Evec stored in Xvec

%We can plot this

plot(Evec,Xvec)

%Put on a grid

grid on

%We can hold the plot, to plot something above,
%for example the same data, with x-marks.

hold on

plot(Evec,Xvec,'x')

