function y = bandgap_kp (outcarinput) fid = fopen(outcarinput); MVB = -9999; MCB = 9999; directBG = 9999; k = 0; tline = fgets(fid); while ischar(tline) outbn = strfind (tline, 'NBANDS='); if size(outbn) > 0 bnlines = strsplit(tline); sbnl = size(bnlines)-1; bnlines = bnlines(sbnl(2)); NBANDS = str2double(bnlines) end out = strfind(tline, 'band No.'); if size(out) > 0 k = k+1; MVBd = -9999; MCBd = 9999; for i=1:NBANDS tline = fgets(fid); nuline = str2num(tline); if (nuline(3)==1) if (nuline(2)>MVBd) MVBd = nuline(2); kpoint_Vdirect = above_line; end if (nuline(2)>MVB) MVB = nuline(2); nband = nuline(1); kpoint_V = above_line; end end if (nuline(3)==0) if (nuline(2)