% Emacs mode header: -*-Octave-*- source. %
function hysteresis
% based on picture Biol Cybern 2017 1d - saturation function
% f = 10:0.01:10000;
%% fX=logspace(1.2,4.2,1000);
fX=logspace(2.3979,3.7482,100);
% sound frequency [Hz]
f_L = 750; % Hz

f_ILD= 1./(1 + exp((-2.*fX+4.*f_L)./f_L)); % 'k'

f_Iback= 1./(1 + exp((-2.*(fX+1000)+4.*f_L)./f_L*10)); % 'm'

f_Iforw= 1./(1 + exp((-2.*(fX-1000)+4.*f_L)./f_L)); % 'r'

% semilogx(fX, f_ITD, 'm'); % 'r','g','b','k'
% hold on
semilogx(fX, f_Iforw, 'r',fX, f_ILD, '-.k',fX, f_Iback, '--m');
% 'Color',[0 0.7 0]);
grid minor
% grid on
% AX.XMinorGrid = 'on';
% grid minor

xlabel('Sound Frequency [Hz]');
ylabel('ILD Response');
axis([10^2.3979, 5600, -0.1, 1.2]); 
%% axis([10^1 10^3.6021 -0.2 1.2])
xticks([250 500 1000 2000 4000]);
yticks([0 0.2 0.4 0.6 0.8 1]);
legend('Forward Cue','ILD','Backward Cue','Orientation','Horizontal')
% ...,'Location','NorthEastOutside')
%%% print('-depsc','fig-h');
%%% unix('eps2pdfpm fig-h')
end
