Code -
% We need to set a tolerance value for the similarity of slopes between the
% main data and the "fusion" data. This tolerance is in degrees, so basically
% means that the fiber must be within TOL degrees left or right of the overall data average.
TOL = 10;
% Slightly different and a more general data probably
L1=[2,3;3,5;4,10];
L2=[7,15;8,19;9,21];
L_fiber = [L1(end,:);L2(1,:)];
% Slopes calculation
a1 = diff(L1);
m1 = a1(:,2)./a1(:,1);
a2 = diff(L2);
m2 = a2(:,2)./a2(:,1);
% Overall slope for the main data
m = mean([m1;m2]);
a_fiber = diff(L_fiber);
m_fiber = a_fiber(:,2)./a_fiber(:,1);
m_fiber_mean = mean(m_fiber);
% Checking if the fiber mean is within the limits set by TOL
deg_max = atan(m)*(180/pi) + TOL;
deg_min = atan(m)*(180/pi) - TOL;
slope_max = tan(deg_max*pi/180);
slope_min = tan(deg_min*pi/180);
if m_fiber_mean >= slope_min && m_fiber_mean <= slope_max
out = true;
disp('Yes the fusion matches the overall data');
else
out = false;
disp('No the fusion does not match the overall data');
end
Hope this settles it!