-
Notifications
You must be signed in to change notification settings - Fork 0
/
OutputDataPlot.m
79 lines (66 loc) · 2.24 KB
/
OutputDataPlot.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
function [fhandle] = OutputDataPlot(data)
% OUTPUTDATAPLOT Plots given FET output curve data on logarithmic plot
%
% Promts user for file with data if no input is given.
%
% Sam Schott, 06.10.2017
%
%% INPUT processing
% check if data structure is given, otherwise ask for file
if nargin==0
data = FETDataRead;
% handle gracefully if no file is selected
if isempty(data)
return;
end
end
% report error if data does not match expected output curve format
if strcmp(data.type,'output')==0
error('Data has the wrong format. Please select a file with output characteristics.');
end
% take absulute values of all currents
data.Id = abs(data.Id); data.Ig = abs(data.Ig);
% Plot output curves
fhandle = figure(); % create new figure
plot(data.x, data.Id, '-');
hold on;
plot(data.x, data.Ig, '--');
hold off;
% create plot legend
for j = 1:length(data.Vstep)
legStr{j} = ['Id (Vg = ', num2str(data.Vstep(j)),'V)'];
%legStr{j+length(data.Vstep)} = ['Ig (Vg = ',num2str(data.Vstep(j)),'V)'];
end
legend(legStr,'Location','southwest');
title('Output characteristics');
xlabel('Source-Drain Voltage (V)');
ylabel('Drain Current (A)');
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,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(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,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]);
hold off;
end