function [Pout,Poutfpps,PoutHp,Pin,Tout,Toutfp,RPM,eta]=motor(Vin,Iin,Kv,Kt,R,Io)
% Iin is input current (amperes), can be scalar or vector
% Io is loss current (No Load Current) (amperes), scalar
% Inet is the net current (amperes), can be scalar or vector
% Vin is input voltage (volts), can be scalar or vector
% Kv RPM per volt
% Kt inch-ounce per ampere
% R ohms
% Io amperes
% Pout output power (watts)
% Poutfpps output power (ft-lbf/sec)
% PoutHp output power (horsepower)
% Pin input power (watts)
% Toutfp torque output (ft-lbf)
% RPM shaft rotation speed, revolutions per minute
% eta motor efficiency (nondimensional)
Inet=Iin-Io;         % amperes
Pin=Vin.*Iin;       % watts
Tout=Kt.*Inet;      % inch-ounce
Toutfp=Tout/(12*16); % ft-lbf
RPM=Kv.*(Vin-Iin*R); %revolutions per minute
Pout=Inet.*(Vin-Iin*R); % watts
Poutfpps=Pout*.7376; % ft-lbf/sec
PoutHp=Pout*.001341; % horsepower
Omega=(2*pi/60)*RPM ; %rad/sec
Poutfpps2=Toutfp.*Omega; % ft-lbf/sec
eta=Pout./Pin;        % motor efficiency (nondimensional)


