function [ee,rr] = calib_fins( fprefix )

% function calib_fins( fprefix )
%
% B. A. Moran, 29-Jul-1997

ii = findstr( fprefix, '/' );

if ~isempty(ii) label = fprefix((max(ii)+1):end);
else label = fprefix;
end

set( gcf, 'Name', ['Fin Calibration: ' label] );

fname = sprintf( '%sE.dat', fprefix );
subplot( 2, 1, 1 );
e = hecubic( fname );
mapping = sprintf( '%sE: x = %.8gy^3 %+.7gy^2 %+.6gy %+.3g', ...
	label, e(1), e(2), e(3), e(4) );
title( mapping )
xlabel( 'M_ELEVATOR_ANGLE (deg)', 'Interpreter', 'none' )
ylabel( 'Hall Effect Sensor' );

code = [];
for ii = 1:4
    code = strvcat( code, sprintf('#define E%d   %+.8e', ii-1, e(5-ii)) );
end
disp( code );


fname = sprintf( '%sR.dat', fprefix );
subplot( 2, 1, 2 );
r = hecubic( fname );
mapping = sprintf( '%sR x = %.8gy^3 %+.7gy^2 %+.6gy %+.3g', ...
	label, r(1), r(2), r(3), r(4) );
title( mapping )
xlabel( 'M_RUDDER_ANGLE (deg)', 'Interpreter', 'none' )
ylabel( 'Hall Effect Sensor' );


code = [];
for ii = 1:4
    code = strvcat( code, sprintf('#define R%d   %+.8e', ii-1, r(5-ii)) );
end
disp( code );

if nargout > 0
    ee = e;
    if nargout > 1
	rr = r;
    end
end
