Professional Documents
Culture Documents
Particle in A Box Plot
Particle in A Box Plot
Ψ = (2/L)^(1/2) * sin(nπx/L)
Where, n = 1, 2, 3………
Code to plot on MATLAB ~:
prompt = 'What is the length of box? ';
L = input(prompt);
x=linspace(0,L);
prompt = 'What do you want your starting n value to be?';
u = input(prompt);
prompt = 'What do you want your ending n value to be?';
t = input(prompt);
figure;
for i=u:t
psi =sin(i*pi*x);
plot(x,psi,'color', rand(1,3),'LineWidth', 2,'DisplayName',sprintf('n
= %d',i));
hold on;
legend('show');
end
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
xlabel ('0 < X < L');
ylabel ('\psi = Wave function')
title('\psi vs x Plot for Different n')
grid on
Input
What is the length of box?
1
What do you want your starting n value to be?
1
What do you want your ending n value to be?
3