Hello Everyone,
Got it. Have attached my code below. If some one could suggest a even more efficient way i would be more than happy to learn.
[filename,pathname] = uigetfile('*.txt');
fullfilename = fullfile(pathname,filename);
A = importdata(fullfilename);
Torque = A(:,1);
Angle = A(:,2);
plot(Torque,Angle)
Torque_min = min(Torque);
Torque_max = max(Torque);
Torque_avg = mean(Torque);
Angle_min = min(Angle);
Angle_max = max(Angle);
Angle_avg = mean(Angle);
Torque=A(:,1);
Angle=A(:,2);
figure;
hold on
plot(Torque,Angle);
xmin=min(Torque);
xmax=max(Torque);
ymin=min(Angle);
ymax=max(Angle);
yavg=mean(Angle);
xavg=xmax;
dtq=diff(Torque);
i=find(dtq<0);
Torque=Torque(i);
Angle=Angle(i);
id = (Torque >= 0);
Torque_Positive = Torque(id);
Angle_Positive = Angle(id);
it = (Torque <=0);
Torque_Negative = Torque(it);
Angle_Negative = Torque(it);
p1 = polyfit(Torque_Positive,Angle_Positive,2);
p2 = polyfit(Torque_Negative,Angle_Negative,2);
plot(Torque_Positive,polyval(p1,Torque_Positive));
hold on
plot(Torque_Negative,polyval(p2,Torque_Negative));