function changeText(hInfo, pt, handles)
% changeText

%   Project: IMPACT
%   Title of Code: changeText
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors.


ptX = pt(1);
ptY = pt(2);

hAx = gca;
hMag = handles.hMag;
hPhase = handles.hPhase;
if hAx==hMag(1) % mag axes is being used
    vecY = get(hMag(2), 'YData');
else
    vecY = get(hPhase(2), 'YData');
end
vecX = handles.Data.w;


dist = abs(ptX - vecX);
[temp, ind] = sort(dist);
vecX = vecX(ind);
vecY = vecY(ind);

xLim = get(gca, 'XLim');
yLim = get(gca, 'YLim');
for m = 1:numel(vecX)
    if checkRange(ptX, ptY, vecX(m), vecY(m), xLim, yLim)
        valX = vecX(m); 
        if hAx==hMag(1)
            strY = sprintf('Magnitude: %g dB', vecY(m));
        else
            strY = sprintf('Phase: %g deg', vecY(m));
        end
        set(hInfo, 'String', {strY, sprintf('Freq: %g rad/s', valX)});
        break;
    end
end
