[MCLdata,MCLdataStructure,dataOut,hWaitBar] =NewMCLDataRead_Begin3('fileName','SVHMCL78.mat ','timePrompt',0)
[theta,r] = cart2pol(x-centroid_x,y-centroid_y);
[t0_pos,s0_pos,t0_neg,s0_neg]= crossing_V7(theta,s,threshold,'linear');
subplot(211),plot(s,theta,t0_pos,s0_pos,'+r',t0_neg,s0_neg,'+g','linewidth',2,'markersize',12);grid on
legend('signal','positive slope crossing points','negative slope crossing points');
subplot(212),plot(s,r,'linewidth',2,'markersize',12);grid on
nb_of_loops = length(t0_pos) -1;
ind_start(ci) = floor(t0_pos(ci));
ind_stop(ci) = ceil(t0_pos(ci+1));
a(ci) = ind_stop(ci) - ind_start(ci);
theta2 = unwrap(theta(ind_start(ci):ind_stop(ci)));
r2 = r(ind_start(ci):ind_stop(ci));
r2all = [r2all; r2(1:maxx)];
theta2all = [theta2all; theta2(1:maxx)];
theta2_mean = mean(theta2all,1);
[u,v] = pol2cart(theta2_mean,r2_mean);
figure(2),plot(LVVol,P_LV,u,v);
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);