Plotting a Graph from Data
이전 댓글 표시
I'm new to MatLab and I'm modelling a semiconductor laser with the aim of plotting 'L' (quantum well width) against 'Band_Gap'. I've previously tried 'plot(L,Band_Gap);' in the command window but it just gives me a blank graph. How would i go about plotting this?
My current code

답변 (1개)
Star Strider
2019년 2월 11일
Try:
figure
plot(L,Band_Gap)
grid
in your script that calculates those values instead.
댓글 수: 8
SKC1997
2019년 2월 12일
Star Strider
2019년 2월 12일
I have no idea.
I cannot run your code, because for some reason, MATLAB will not run images of code. If you copy your code from your Editor and paste it to a Comment here, I will probably be able to run it, and I might be able to help.
SKC1997
2019년 2월 12일
Star Strider
2019년 2월 12일
Both ‘L’ and ‘Band_Gap’ are single points:
L =
6.000000000000001e-09
Band_Gap =
0.808866986571398
I see only constants in your code, (when I look at the Workspace window), no vectors. If you want to plot a range of ‘Band_Gap’ values as a function of a range of ‘L’ values, you have to create them all as vectors. Single points will only display if you plot them with a marker:
figure
plot(L, Band_Gap, 'p')
grid
However, this would not be very informative with only one point.
SKC1997
2019년 2월 12일
Star Strider
2019년 2월 12일
Choose a range of values for ‘L’, then create a vector for it.
For example:
L = linspace(1, 10, 150)*1E-9; % <—— CREATE VECTOR ‘L’
I would then create ‘EC1’ and everything else that uses ‘L’ to be numeric funcitons of ‘L’. (I tried to do this myself, but your code is too difficult for me to follow.) This may require that you use numeric solvers such as fsolve instead of the symbolic vpasolve or solve, and use various values of ‘L’ to calculate ‘EV1’ and the others in a loop. That would be inefficient and time-consuming, so it is likely best that you devise a different approach.
First, eliminate the syms call, and all the symbolic solve calls, so all the variables are now numeric.
The last section of your code is now:
%% Schroedinger for well energy levels
%Reaplaced GaInAsSbBi with GaInPAs
format long
hbar = 6.582119514E-16 ; % reduced Planc constant in eVs
Lv = linspace(1, 10, 150)*1E-9; % <—— CREATE VECTOR ‘L’
mC = m_GaInPAs_c*(5.686462E-12) ; % Effective mass in conduction band. Numeric term to convert from multiples of electron mass to eVm^-2s^2 so equation has consistent units.
mH = m_GaInPAs_h*(5.686462E-12) ; % Effective mass in valence band. Numeric term to convert from multiples of electron mass to eVm^-2s^2 so equation has consistent units.
mS = m_GaInPAs_s*(5.686462E-12) ; % Effective mass in split-off band. Numeric term to convert from multiples of electron mass to eVm^-2s^2 so equation has consistent units.
UC = ECBGaInPAs - ECBGaInPAs_Well; % Well depth for Conduction Band. SC - NOT SURE... ORIGINAL(UC = ECBGaInAsVEC - ECBGaInPAs)
UH = abs(EVBGaInPAs - EVBGaInPAs_Well); % Well depth for Valence Band. SC - NOT SURE... ORIGINAL(UH = EVBGaInPAs - EVBGaInAsVEC)
US = abs(ESOGaInPAs - ESOGaInPAs_Well); % Well depth for Spin-Orbit Split-off Band. SC - NOT SURE... ORIGINAL(UH = EVBGaInPAs - EVBGaInAsVEC)
for k1 = 1:numel(Lv)
L = Lv(k1);
EC1(k1) = fsolve(@(EC) tan(sqrt((2*mC*EC*L^2)/hbar^2)) - (2*sqrt((UC-EC)*EC))/(2*EC-UC), 1);
EV1(k1) = fsolve(@(EV) tan(sqrt((2*mH*EV*L^2)/hbar^2)) - (2*sqrt((UH-EV)*EV))/(2*EV-UH), 1);
ES1(k1) = fsolve(@(ES) tan(sqrt((2*mS*ES*L^2)/hbar^2)) - (2*sqrt((US-ES)*ES))/(2*ES-US), 1);
end
% ^ Offset of first energy level in conduction band. May have to adjust
% factor under UC until returns an error, use a value smaller than that to
% get lowest energy level.
% ^ Offset of first energy level in valence band.May have to adjust
% factor under UH until returns an error, use a value smaller than that to
% get lowest energy level.
% ^ Offset of first energy level in split-off band.May have to adjust
% factor under US until returns an error, use a value smaller than that to
% get lowest energy level.
EnC = double(EC1+ECBGaInPAs); %SC - Swapped GaInAsSbBi for GaInPAs
EnV = double(EVBGaInPAs-EV1); %SC - Swapped GaInAsSbBi for GaInPAs
EnS = double(ESOGaInPAs-ES1); %SC - Swapped GaInAsSbBi for GaInPAs
Band_Gap = (EnC)-(EnV)
Spin_Orbit_Splitting = (EnV)-(EnS) ;
Wavelength = ((4.135667516E-15)*299792458)./Band_Gap
figure
plot(Lv, real(Band_Gap))
grid
This runs without error, and is actually faster than I thought it would be.
Experiment to get the result you want.
Star Strider
2019년 2월 12일
My pleasure.
If my Answer helped you solve your problem, please Accept it!
카테고리
도움말 센터 및 File Exchange에서 Eigenvalue Problems에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
