Untitled
unknown
matlab
a year ago
398 B
1
Indexable
Never
numSteps = 100; C = [1, 1; 1, -1] / sqrt(2); psi = zeros(2, 2*numSteps+1); psi(2, numSteps+1) = 1; for step = 1:numSteps psi = C * psi; psi = [circshift(psi(1,:), [0, 1]); circshift(psi(2,:), [0, -1])]; end prob_distribution = sum(abs(psi).^2, 1); positions = -numSteps:numSteps; plot(positions, prob_distribution, 'LineWidth', 2); xlabel('Position'); ylabel('Sannolikhet'); grid on;