Update: I added a lower bound so the results couldn't be negative. And now I have the graph attached. It's linear but I'm not sure why.
Issue Using lsqcurvefit to find solar cell parameters
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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-')
Antworten (1)
Dimitris Iliou
am 21 Apr. 2017
The issue with the code that you have attached, lies with the dimensions of the signal created by the fun function.
If you copy this code into a .m file and you run it, it should not work. It gives an error saying:
Matrix dimensions must agree.
Error in @(v,vdata)v(1)*(exp(q*(vdata-v(2)*idata)/(v(3)*kB*T))-1)+(vdata-v(2)*idata)/v(4)
The reason for that error is because you use idata in that formula. By using that, you change the dimension of the output signal.
If you replace your fun command with the following:
fun = @(v, vdata) v(1)*(exp(q*(vdata - v(2))/(v(3)*kB*T)) -1) + (vdata-v(2))/v(4);
the code will produce the following graph:
There are good examples in the lsqcurvefit documentation page:
The main thing that you should notice in those examples, is that when the fun function is defined, the ydata variable (similar to your idata) is not used.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Web Services finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!