function ee340lab6(Sep, Shunt, CumComp, DiffComp, Series)
for k=1:1:5; 
  if k==1, data6=Sep;     
     fprintf('\n\n     Table I:  Results for the separately excited dc generator \n')

       	elseif k==2, data6=Shunt;
   	fprintf('\n\n     Table II:  Results for the shunt excited dc generator \n')
   	elseif k==3; data6=CumComp;
     fprintf('\n\n   Table III:  Results for the cumulatively compound dc generator \n') 
     elseif k==4; data6=DiffComp;
     fprintf('\n\n    Table IV:  Results for the differentially compound dc generator \n')
		elseif k==5; data6=Series;
     fprintf('\n\n     Table V:  Results for the series dc generator \n') 
   	else, end      
    	V= data6(:,1)';        % Terminal voltage 
		Ia=data6(:,2)';        % Armature current  
		If=data6(:,3)';        % Field current 
   	n= data6(:,4)';        % Speed in RPM 
		Pull =data6(:,5)';     % Pull in Kg
   	% Calculated data          
      	if k==1|k==5, IL=Ia; % Separately & series excited generator  
        else, IL = Ia-If;   % Shunt & Compound     
        end    
     Po = V.*IL;            % Generator output power
		T=Pull*9.81*0.305;     % Torque Eq. (6.7)
		w = 2*pi*n/60;         % Speed in Dad/sec.
		Pi=w.*T;               % Generator input power Eq. (6.8)
		Eff = Po./Pi*100;      % Motor efficiency 
      
    fprintf(['\n    V        I_a     I_f       n        Pull    I_L      P_0     T        P_i       Eff\n'])
		fprintf('%7.2f %6.2f %5.2f %7.1f %6.2f %6.2f %8.2f %5.2f %8.2f %6.2f\n',[V;Ia;If;n;Pull;IL;Po;T;Pi;Eff]);
  %fprintf('\n     Calculated values \n')
%
 %   fprintf(['\n      \n'])
%		fprintf('\n',[]);
%  Terminal voltage & Eff. plots
nV(1)= 1; nV(2)= 2; nV(3)=2; nV(4)=2; nV(5)=2; % Poly. order for curve fitting
																		 	 % if necessary change the order  
cV=polyfit(Ia, V,nV(k));  % Returns polynomial coefficients for V-curve   
Vfit=polyval(cV, Ia);     % Evaluates the polynomial values for V-curve
nE(1)= 3; nE(2)=3; nE(3)=3; nE(4)=3; nE(5)=3; % poly. order, for curve fitting
																			% if necessary change the order 
cE=polyfit(Po, Eff, nE(k));  % Returns polynomial coefficients for Eff-curve  
Efffit=polyval(cE, Po);      % Evaluates the polynomial values for Eff-curve
if k==1, figure(1), plot(Ia, V,'xr', Ia, Vfit, 'r')
   hold on
   figure(2), plot(Po, Eff, 'xr', Po, Efffit, 'r' )
   hold on
	elseif k==2, figure(1), plot(Ia, V,'xb', Ia, Vfit, 'b')
                figure(2), plot(Po, Eff, 'xb', Po, Efffit, 'b') 
	elseif k==3, figure(1), plot(Ia, V,'xm', Ia, Vfit, 'm')
               figure(2), plot(Po, Eff, 'xm', Po, Efffit, 'm')
	elseif k==4, figure(1), plot(Ia, V,'xk', Ia, V, 'k')
               figure(2), plot(Po, Eff, 'xk', Po, Efffit, 'k')
	elseif k==5, figure(1), plot(Ia, V,'xg', Ia, Vfit, 'g')
               figure(2), plot(Po, Eff, 'xg', Po, Efffit, 'g') 
else, end
figure(1), Legend('Sep.', ' ',' Shunt', ' ', 'Cum.',' ','Diff.',' ','Series', ' ', 4)
figure(1),title('DC Generator Load Characteristics - Terminal voltage')
figure(1), xlabel('I_a, Amps'), 
figure(1), ylabel('V, Volts')
figure(2), title('DC Generator Load Characteristics - Efficiency')
figure(2), xlabel('P_o, Watt')
figure(2), ylabel('\eta, %')
figure(2), Legend('Sep.', ' ',' Shunt', ' ', 'Cum.',' ','Diff.',' ','Series', ' ', 4)
end


