function p = hecubic( fname )

[fid,message] = fopen( fname, 'r' );
if fid == -1, error( message ); end
[a, count] = fscanf( fid, '%x %f' );
fclose( fid );

rawHE = a(1:2:count);
finpos = a(2:2:count);
[p,S] = polyfit( rawHE, finpos, 3 );
y = linspace( min(rawHE), max(rawHE), 256 );
[x,delta] = polyval( p, y, S );

plot( finpos, rawHE, 'or', x, y, 'm', x-delta, y, 'b', x+delta, y, 'b' );

ytick = get( gca, 'ytick' );
m = length( ytick );
for i = 1:m
    if i == 1
	ylabel = sprintf( '0x%x', ytick(i) );
    else
	ylabel = str2mat( ylabel, sprintf( '0x%x', ytick(i) ) );
    end
end
set( gca, 'yticklabels', ylabel );
set( gca, 'xtick', -40:10:40 );
