function output = hex2uint8(instr) % HEX2UINT8 -- Hexidecimal string converter. % Converts hexdecimal ascii into unsigned 8 bit integer. % % 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 % Re-written for speed by M.Godin; 03 Aug 2004 % Version prior to 03 Aug 2004: %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; % High-speed version output = hex2dec(reshape(instr,2,length(instr)/2)')';