function ee340lab8(IMinput)
I1 = IMinput(:,2)';      % Stator line current
P1 = IMinput(:,3)';      %  Wattmeter reading W1  
P2 = IMinput(:,4)';      %  Wattmeter reading W2 
n =  IMinput(:,5)';      %  Speed in RPM
Pull=IMinput(:,6)';      % Pull in Kg
% Calculated data          
Pi = P1+P2;              % Motor input power
T=Pull*9.81*0.305;       % Torque Eq. (7.11)
w = 2*pi*n/60;           % Speed in Rad/sec.
Po=(w.*T);               % Motor output power Eq. (8.17)
Eff = (Po./Pi*100);      % Motor efficiency 
th=atan(sqrt(3)*(P1-P2)./(P1+P2));
pf=cos(th);
ns=input('Enter the synchronous speed in RPM, ns = ');
S=((ns-n)/ns);							% Slip

fprintf('\n\n     Table I:  Measured Data \n')
V  = IMinput(:,1)';      % Line-to-line voltage 

fprintf(['\n     V(V)    I_1(A)   P_1(W)      P_2(W)    n(RPM)    Pull, kg\n'])   
fprintf('%10.2f %8.2f %11.2f %10.2f %11.2f %9.2f\n', [V; I1; P1; P2; n; Pull]);  

fprintf('\n\n           Results for the Squirrel cage Induction Motor \n')

fprintf(['\n   P_i(W)   T(N-m)    P_0(W)    Slip          pf          Eff\n'])
fprintf('%9.2f %9.2f %11.2f %10.3f %10.3f %10.2f\n',[Pi; T; Po; S; pf; Eff]);
% Current and Torque Vs. Speed plots
nI= 2; nT=3;							% Poly. order for curve fitting
													% if necessary change the order  
CI=polyfit(n, I1,nI);  	% Returns polynomial coefficients for I1/n curve   
Ifit=polyval(CI, n);    % Evaluates the polynomial values for I1/n curve
figure(1), plot(n, I1, 'xr', n, Ifit, 'r' )
CT=polyfit(n, T,nT);  	 	% Returns polynomial coefficients for T/n curve   
Tfit=polyval(CT, n);   	% Evaluates the polynomial values for T/n curve
hold on
figure(1), plot(n, T, 'xb', n, Tfit, 'b' )
figure(1), Legend('I_1', ' ','T', ' ', 3)
figure(1),title('Stator current and Developed Torque Vs. Speed')
figure(1), xlabel('n, RPM'), 
figure(1), ylabel('I_1 (A) & T (Nm)')
hold off
Eff=Eff/100;
% Pf and efficiency Vs. Speed plots
npf= 2; nE=2;							% Poly. order for curve fitting
													  % if necessary change the order  
Cpf=polyfit(n, pf,npf);  	% Returns polynomial coefficients for pf/n curve   
pffit=polyval(Cpf, n);    % Evaluates the polynomial values for pf/n curve
figure(2), plot(n, pf, 'xr', n, pffit, 'r' )
CE=polyfit(n, Eff,nE);  	% Returns polynomial coefficients for Eff/n curve   
Efit=polyval(CE, n);     	% Evaluates the polynomial values for Eff/n curve
hold on
figure(2), plot(n, Eff, 'xb', n, Efit, 'b' )
figure(2), Legend('pf', ' ','P.U. \eta',' ', 3)
figure(2),title('Power factor and Per-unit Efficiency Vs. Speed')
figure(2), xlabel('n, RPM'), 
figure(2), ylabel('pf & P.U. \eta')
hold off







