Since I haven't received any answers, i did an attempt to create a similar function my self.
% Calculates the slope and offset between two interactively chosen points % in a plot. Then plots the points plus curve and writes out slope and offset in the title of figure. % Can be used to calculate resistance in I-V curves for instance. % Select two points, first point to the left of second point.
function SlopeCalc
X=ginput;
k=(X(2,2)-X(1,2))/(X(2,1)-X(1,1));
m=X(1,2)-X(1,1)*k;
title({'Slope: ',num2str(k),' M value: ',num2str(m)})
plot([X(1,1),X(2,1)],[X(1,1),X(2,1)].*k+m,'ko-')
end