How to plot rectangular potential in matlab

I will try to plot something like this :
Observ that this is a rectangular potential barrier, the dashed line is the classical result of the potential U and the blue line is the quantum mechanics. The tunneling regime takes the place at intersection of the dashed line and the blue line; and the tops of the blue line is called the resonance which I have to show. My attempt is
clc
clear all
m=9.11 * 10^(-31);
U=5e-19;
E=0e-19:0.001e-19:12e-19;
a=3e-9;
h=1.36e-34;
k=sqrt(2*m.*(U-E));
k2=k/h;
c=(U^2)*(sinh(0.5*a*k2).^2)./(4*E.*(U-E));
T=1./(1+c);
plot(E,T)
But how can I get a plot like this ?

 채택된 답변

Star Strider
Star Strider 2018년 11월 8일

1 개 추천

Your code appears to be correct. If you want the labels, try this:
m=9.11E-31;
U=5e-19;
E=0e-19:0.001e-19:12e-19;
a=3e-9;
h=1.36e-34;
k=sqrt(2*m.*(U-E));
k2=k/h;
c=(U^2)*(sinh(0.5*a*k2).^2)./(4*E.*(U-E));
T=1./(1+c);
[respks, locs] = findpeaks(T);
figure
plot(E,T)
hold on
plot([0.5 0.5]*1E-18, ylim, '--r')
hold off
text(E(locs+275), respks*0.99, compose('\\bf{\\leftarrow res %d}', 1:3), 'HorizontalAlignment','left', 'VerticalAlignment','top', 'Rotation', -75)
text(0.5E-18, 0.1, sprintf('\\bftunneling \\rightarrow'), 'HorizontalAlignment','right')
Experiment to get the result you want.

댓글 수: 8

Pouyan Msgn
Pouyan Msgn 2018년 11월 8일
Yes but the step function; U has the value 5e-19; how I can plot that ?
Plot it as a continuous function:
m=9.11E-31;
U=5e-19;
E=0e-19:0.001e-19:12e-19;
a=3e-9;
h=1.36e-34;
k=sqrt(2*m.*(U-E));
k2=k/h;
c=(U^2)*(sinh(0.5*a*k2).^2)./(4*E.*(U-E));
T=1./(1+c);
stp = @(x) x >= 0;
[respks, locs] = findpeaks(T);
figure
plot(E,T)
hold on
plot(E, stp(E-U), '--r')
hold off
text(E(locs+275), respks*0.99, compose('\\bf{\\leftarrow res %d}', 1:3), 'HorizontalAlignment','left', 'VerticalAlignment','top', 'Rotation', -75)
text(0.5E-18, 0.1, sprintf('\\bftunneling \\rightarrow'), 'HorizontalAlignment','right')
This is essentially the same as before, changed to include the addition of the ‘stp’ anonymous function, and the plot call that plots it as a step function.
Pouyan Msgn
Pouyan Msgn 2018년 11월 8일
Thank you ^_^
Star Strider
Star Strider 2018년 11월 8일
My pleasure.
If my Answer helped you solve your problem, please Accept it!
Pouyan Msgn
Pouyan Msgn 2018년 11월 8일
But one thing I get this error when I run it : Undefined function 'compose' for input arguments of type 'char'.
Error in Q3a (line 21) text(E(locs+275), respks*0.99, compose('\\bf{\\leftarrow res %d}', 1:3), 'HorizontalAlignment','left', 'VerticalAlignment','top', 'Rotation', -75)
Star Strider
Star Strider 2018년 11월 8일
편집: Star Strider 2018년 11월 8일
The compose function was introduced in R2016b.
This should work:
text(E(locs+275), respks*0.99, sprintfc('\\bf{\\leftarrow res %d}', 1:3), 'HorizontalAlignment','left', 'VerticalAlignment','top', 'Rotation', -75)
Note — The sprintfc function is officially undocumented.
Pouyan Msgn
Pouyan Msgn 2018년 11월 8일
Thanks and I clicked on accepted
Star Strider
Star Strider 2018년 11월 8일
As always, my pleasure!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Quantum Mechanics에 대해 자세히 알아보기

태그

질문:

2018년 11월 8일

댓글:

2018년 11월 8일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by