Professional Documents
Culture Documents
Denote
init_conds=[1; i*k]; Remember the x value used in k should be where we want to start the integration Solving the ODE: options = odeset(reltol, 1e-5); [x,PsiPhi]=ode45(schrodinger, x, init_conds, options, E); Define psi and phi: psi=PsiPhi(:, 1); phi=PsiPhi(;, 2);
Summing Probabilities
Copy data up to a certain n and place it in a matrix, eg wavefunction. The probability of each n will be the square of each element in wavefunction so we square the elements and take the transpose of this new matrix such that the dimensions are correct. Then type sum(probability,1) in Matlab to sum all the probabilities.