I am trying to use lsqcurvefit to fit I-V data collected from a solar cell to find different solar cell parameters. However, I am getting a weird graph (picture attached). Does anyone know what I am doing wrong? I wasn't sure what to make my initial data, could that be the problem? Thanks! CODE:
T = 300; kB = 8.6173303*10^-5; q = 1.6*10^-19;
vdata = [ 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.8 0.81 0.82 0.83 0.84 0.85 0.87];
idata = [-0.00046 0.00302 0.007 0.01148 0.01546 0.01944 0.02392 0.0284 0.03388 0.03786 0.05234 0.05632 0.0623 0.07026];
fun = @(v, vdata) v(1)*(exp(q*(vdata - v(2)*idata)/(v(3)*kB*T)) -1) + (vdata-v(2)*idata)/v(4); v0 =[1,1,1,1];
v = lsqcurvefit(fun, v0, vdata, idata)
hold on times = linspace(vdata(1), vdata(end)); plot(vdata,idata, 'ko', times, fun(v, times), 'b-')