y = sin(3*x-1).*exp(-x/10);
[tf, P] = islocalmax(y,'MinProminence',max(y)/3);
[t0_pos,s0_pos,t0_neg,s0_neg]= crossing_V7(y,x,threshold,'linear');
plot(x,y,x_antinodes,y_antinodes,'dk',x,threshold*ones(size(x)),'k--',t0_pos,s0_pos,'dr',t0_neg,s0_neg,'dg','linewidth',2,'markersize',12);grid on
legend('signal','antinodes','nodes level threshold','positive slope nodes','negative slope nodes');
function [t0_pos,s0_pos,t0_neg,s0_neg] = crossing_V7(S,t,level,imeth)
error(nargchk(1,4,nargin));
if nargin < 2 | isempty(t)
elseif length(t) ~= length(S)
error('t and S must be of identical length!');
S1 = S(1:end-1) .* S(2:end);
if strcmp(imeth,'linear')
if abs(S(ind(ii))) >= eps*abs(S(ind(ii)))
NUM = (t(ind(ii)+1) - t(ind(ii)));
DEN = (S(ind(ii)+1) - S(ind(ii)));
slope_sign(ii) = sign(slope);
t0(ii) = t0(ii) - S(ind(ii)) * slope;
ind_pos = find(sign(slope_sign)>0);
ind_neg = find(sign(slope_sign)<0);