%  This script demonstrates the used of mfiles
%  GETCURVES and INTERPCURVES for opening the
%  Transfer Characteristic of a FET from the
%  Curve Tracer and converting it to a matrix
%  where rows represent the ids family of curves 
%  for each Gate-Source voltage. Sparate vectors
%  for vgs and vds are generated 
%
%  It needs the CSV data  file 'E121555E.CSV' in the 
%  Current director to run


%  Open CSV curve from Curve Tracer Output File 
fname = ['E121555E.CSV'];
vstep = [1.496:.2:2.696];  % Need to provide the step sequence
c = getcurves(fname,vstep);
%  Convert Cell Array to vector
[ids, vds, vgs] = interpcurves(c);
% Plot it for observation
figure(1)
plot(vds,ids*1000)
title('FET Transfer Characteristic')
xlabel('v_d_s in Volts')
ylabel('i_d_s in milliamps')

%  Let's get fancy and write the Vgs values
%  on the plot near each TC it corresponds to
hold on
% Step through vgs vector and write number on plot
for k=1:length(vgs)
    text(mean(vds),1000*max(ids(k,:)),num2str(vgs(k),2))
end
hold off