ECE_456_Reports/PS2/q4b_subplots.m
2021-03-05 15:25:31 -07:00

114 lines
6.4 KiB
Matlab

% Code to create the required subplots for Problem Set 2, Problem 5(b)
% If you've used the same variable names as in the sample code, then you
% should be able to simply insert this into the appropriate spot in your
% own code; otherwise, you'll have to modify this accordingly, which
% should be easy to do---if disaster strikes and it doesn't work, then
% please ask for help
% The "if" statement is used to choose VD values closest to the required
% values of 0.0, 0.2, 0.3, ..., 0.8 V, and you don't need to
% worry about how this works
if (abs(VD-0.0) <= dV/2)
figure(3); title('VD = 0.0 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.0 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.0 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.0 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.0 V');
elseif (abs(VD-0.2) <= dV/2)
figure(4); title('VD = 0.2 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.2 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.2 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.2 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.2 V');
elseif (abs(VD-0.25) <= dV/2)
figure(5); title('VD = 0.25 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.25 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.25 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.25 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.25 V');
elseif (abs(VD-0.3) <= dV/2)
figure(6); title('VD = 0.3 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.3 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.3 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.3 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.3 V');
elseif (abs(VD-0.4) <= dV/2)
figure(7); title('VD = 0.4 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.4 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.4 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.4 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.4 V');
elseif (abs(VD-0.5) <= dV/2)
figure(8); title('VD = 0.5 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.5 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.5 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.5 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.5 V');
elseif (abs(VD-0.6) <= dV/2)
figure(9); title('VD = 0.6 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.6 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.6 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.6 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.6 V');
elseif (abs(VD-0.65) <= dV/2)
figure(10); title('VD = 0.65 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.65 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.65 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.65 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.65 V');
elseif (abs(VD-0.7) <= dV/2)
figure(11); title('VD = 0.7 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.7 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.7 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.7 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.7 V');
elseif (abs(VD-0.8) <= dV/2)
figure(12); title('VD = 0.8 V');
subplot(2,3,1); plot(f1,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)'); ylabel('ENERGY [eV]'); title('VD = 0.8 V');
subplot(2,3,2); plot(D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.8 V');
subplot(2,3,3); plot(f2,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f2(E)'); ylabel('ENERGY [eV]'); title('VD = 0.8 V');
subplot(2,3,5); plot(f1-f2,E,'--',D/100,E,'k-'); axis([-0.1 1.1 -1 1]);
xlabel('f1(E)-f2(E), D(E-U)/100'); ylabel('ENERGY [eV]'); title('VD = 0.8 V');
end