function output = hex2uint8(instr) % HEX2UINT8 -- Hexidecimal string converter. % Converts hexdecimal ascii into unsigned 8 bit integer. % Used for reading hydrorad files from oasis. % % Use as: hex2uint8(instr) % Inputs: instr = string of hex characters % Output: output = a vector of integers which can be converted % into characters by using char(output) % % Created by K.M. Flynn % Documented by E.Palomino; 20 Sep 2000 n = length(instr)/2; tmpstr = double(instr) - 48; tmpstr(find(tmpstr>9)) = tmpstr(find(tmpstr>9)) - 7; tmpstr(find(tmpstr>15)) = tmpstr(find(tmpstr>15)) - 32; tmpout = []; for i=1:n j=2*(i-1)+1; tmpout(i) = 16*tmpstr(j) + tmpstr(j+1); end output = tmpout;