# MATLAB: I want to solve an equation for I where I have V values. But I am getting error on using fsolve. Failure in initial objective function evaluation.

equationfsolveiteration

Here is my code
clc
clear all
close all
q = 1.602E-19; % C or [J/eV]
kb = 1.38E-23; % [J/K]
eps = 1.05E-12; % This includes the eps = 11.7 for Si [F/cm]
T = 300; % [K]
ni = 1.5E10; % Intrinsic carrier concentration [1/cm^3]
phit = kb*T/q; % [eV]
dn = 30; % cm^2/sec
dp = 15; % do
ln = 0.006; % cm
lp = 0.006; % cm
tau = 1e-6; % sec
rn = 5000; % ohm
rp = 5000; % ohm
area= 1e-4; % cm^2
% Define Doping Values %
Na = 1E17; % [1/cm^3]
Nd = 1E16; % [1/cm^3]
% Calculate relevant parameters for the simulation %
Vbi = phit*log(Na*Nd/(ni*ni));
V=0:0.1:3;
W= sqrt(2*eps*(Na+Nd)*(Vbi-V)/(q*Na*Nd)); % [cm]
Ioidr = q*area*ni*ni*(dp/(lp*Nd)+dn/(ln*Na));
Iogr = q*area*(sqrt(2*eps*(Na+Nd)*(Vbi)/(q*Na*Nd)))*ni/(2*tau);
eqn=@(I) -I+Ioidr*(exp((V-I.*(rp+rn))/phit)-1)+(q*area*(sqrt(2*eps*(Na+Nd)*(Vbi-V+I*(rp+rn))/(q*Na*Nd)))*ni/(2*tau))*(exp((V-I.*(rp+rn))/(2*phit)));
I_sol=fsolve(eqn,zeros(size(V)))
plot(V,I_sol)
set(gca,'Yscale','log')
``eqn=@(I) -I+Ioidr.*(exp((V-I.*(rp+rn))/phit)-1)+(q*area*(sqrt(2*eps*(Na+Nd)*(Vbi-V+I.*(rp+rn))/(q*Na*Nd)))*ni/(2*tau)).*(exp((V-I.*(rp+rn))/(2*phit)));``