function diff = MJRcomp(params,V,I,T)
% This function is called by LSQNONLIN.
% params is a vector which contains the coefficients of the
% equation. V and R are the option data sets that were
% passed to lsqnonlin.
 
Z= params(1);
% Equation of fit
% I = I0 * (exp(q*Va/(Kb*T)) - 1)
% I0 is the fit parameter
%  http://en.wikipedia.org/wiki/Elementary_charge
q = 1.6*(10^-19); % 1.602176565(35)×10?19 C[1]
% http://en.wikipedia.org/wiki/Boltzmann_constant
% Kb = 8.617*(10^-5); %8.617?3324(78)×10?5	eV?K?1
Kb = 1.3806503* (10^-23);

Inew = Z* (exp((q*V)/(Kb*T)) -1);
diff = I - Inew;

end