-
Notifications
You must be signed in to change notification settings - Fork 0
/
TransferDataPlot.m
124 lines (101 loc) · 3.64 KB
/
TransferDataPlot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
function TransferDataPlot(data)
% TRANSFERDATAPLOT Plots given FET transfer curve data on logarithmic plot
%
% Promts user for file with data if no input is given.
%
% Sam Schott, 06.10.2017
%
if nargin == 0
% promt user to select a file
data = FETDataRead;
if isempty(data)
return;
end
elseif isstring(data) || ischar(data)
% load from given path
data = FETDataRead(data);
end
% take absolute vales of currents
data.Id = abs(data.Id);
try
data.Is = abs(data.Is);
catch
data.Is = abs(data.Id);
end
data.Ig = abs(data.Ig);
% check if data matches expected transfer curve format
if strcmp(data.type, 'transfer') == 0
error('Data has the wrong format. Please select a file with transfer characteristics.');
end
% Plot transfer curves
fhandle = figure(); % open new figure
hs = ishold;
plot(data.x, data.Id, '-');
figure(fhandle); hold on;
plot(data.x, data.Is ,'-');
figure(fhandle); hold on;
plot(data.x, data.Ig, '--');
set(gca, 'YScale', 'log'); % set log scale
% create plot legend
for j=1:length(data.Vstep)
legStr{j} = ['Id (Vd = ', num2str(data.Vstep(j)), 'V)'];
legStr{j+length(data.Vstep)} = ['Is (Vd = ', num2str(data.Vstep(j)), 'V)'];
legStr{j+2*length(data.Vstep)} = ['Ig (Vd = ', num2str(data.Vstep(j)), 'V)'];
end
legend(legStr, 'Location', 'southwest');
title(['Transfer characteristics: ' data.title],'Interpreter','none');
xlabel('Gate Voltage (V)');
ylabel('Drain Current (A)');
set(gca, 'YMinorTick', 'on');
xlim([min(data.x) max(data.x)]);
%% Create arrows for hysteresis
% position of arrow
x1 = data.x(round(0.7*length(data.x)/2));
x2 = data.x(round(0.75*length(data.x)/2));
% check for direction of hysteresis loop
slice = data.Id(data.x<-20, end);
fwd_sweep = slice(1:end/2);
bwd_sweep = flipud(slice(end/2+1:end));
if mean(fwd_sweep - bwd_sweep) > 0
offset = 0.02;
else
offset = -0.02;
end
% forward arrow
p1 = [x1 data.Id(data.x(1:end/2)==x1, end)];
p2 = [x2 data.Id(data.x(1:end/2)==x2, end)];
[p1nx, p1ny] = normalize_coordinate(p1(1), p1(2), get(gca, 'Position'), xlim, ylim, 0, 1);
[p2nx, p2ny] = normalize_coordinate(p2(1), p2(2), get(gca, 'Position'), xlim, ylim, 0, 1);
annotation(fhandle, 'arrow', [p1nx p2nx], [p1ny+offset p2ny+offset]);
% backward arrow
p1 = p1 + [0 diff(data.Id(data.x==x1, end))];
p2 = p2 + [0 diff(data.Id(data.x==x2, end))];
[p1nx, p1ny] = normalize_coordinate(p1(1), p1(2), get(gca, 'Position'), xlim, ylim, 0, 1);
[p2nx, p2ny] = normalize_coordinate(p2(1), p2(2), get(gca, 'Position'), xlim, ylim, 0, 1);
annotation(fhandle, 'arrow', [p2nx p1nx], [p2ny-offset p1ny-offset]);
%% Plot sqrt of saturation curve
fhandle = figure(); % open new figure
SqrtSat = sqrt(data.Is(:, end)); hold on;
plot(data.x, SqrtSat, '-');
title(['Transfer characteristics: ' data.title],'Interpreter','none');
xlabel('Gate Voltage (V)');
ylabel('Sqrt of Drain Current (Sqrt(A))');
legend('Saturation current', 'Location', 'southwest');
box on;
% forward arrow
p1 = [x1 SqrtSat(data.x(1:end/2)==x1)];
p2 = [x2 SqrtSat(data.x(1:end/2)==x2)];
[p1nx, p1ny] = normalize_coordinate(p1(1), p1(2), get(gca, 'Position'), xlim, ylim, 0, 0);
[p2nx, p2ny] = normalize_coordinate(p2(1), p2(2), get(gca, 'Position'), xlim, ylim, 0, 0);
annotation(fhandle, 'arrow', [p1nx p2nx], [p1ny+offset p2ny+offset]);
% backward arrow
p1 = p1 + [0 diff(SqrtSat(data.x==x1))];
p2 = p2 + [0 diff(SqrtSat(data.x==x2))];
[p1nx, p1ny] = normalize_coordinate(p1(1), p1(2), get(gca, 'Position'), xlim, ylim, 0, 0);
[p2nx, p2ny] = normalize_coordinate(p2(1), p2(2), get(gca, 'Position'), xlim, ylim, 0, 0);
annotation(fhandle, 'arrow', [p2nx p1nx], [p2ny-offset p1ny-offset]);
if hs == 0
hold off;
end
end