Prev: Function eval - Matlab 7.0 x Matlab 2010a
Next: Data Exchange Between Matlab and Third Party Software like
From: Ryan Need on 22 Jun 2010 15:33 Hello everyone, I need help fitting a physically-known equation with unknown parameters to measured experimental data. The equation represents the I-V behavior of an ideal photovoltaic device (solar cell) and is as follows: I = A - B((e^CV)*(e^CGI) - 1) - DV - DGI where I is the current, V is the voltage and A, B, C, D and G are the parameters to be fit. I've been trying to use the least-squares nonlinear function (LSQNONLIN) with the following code, but I keep getting error messages: >> function diff = fit_simp(x,X,Y); A=x(1); B=x(2); C=x(3); D=x(4); G=x(5); diff = A - B.*(exp(C.*X)*exp(C.*G.*Y) - 1) - D.*X - D.*G.*Y - Y; X=V; Y=I; X0=[1 1 1 1 1]'; options = optimset('Largescale','off'); x=lsqnonlin(@fit_simp,X0,[],[],options,X,Y); If you know what's wrong with this code or if you know of a better way to fit my data to the I-V equation above, I would be very appreciative. Sincerely, R. Need
From: Miroslav Balda on 22 Jun 2010 16:53 "Ryan Need" <rneed(a)clemson.edu> wrote in message <hvr364$e4l$1(a)fred.mathworks.com>... Hi, Could you supply measured V and I vectors and displayed error messages? Mira
From: sam ng on 20 Jul 2010 08:34
"Miroslav Balda" <miroslav.nospam(a)balda.cz> wrote in message <hvr7rh$nqs$1(a)fred.mathworks.com>... > "Ryan Need" <rneed(a)clemson.edu> wrote in message <hvr364$e4l$1(a)fred.mathworks.com>... > Hi, > Could you supply measured V and I vectors and displayed error messages? > Mira Sorry to hijack this thread but i am on the same problem where i have to fit data i have with a solar cell model i have 2 sets of data v and i, 904 points each currently they are set up as column vectors i have set up 3 functions to achieve the fitting initeval, which is used to calculate isat and isc diodemodel, which takes the two outputs from the above function and houses my main equation function F = diodemodel(x,i,v) K = 1.38e-23; T = 298.15; %25 degrees in Kelvin q = 1.6e-19; [isat,isc] = initeval; N=x(1); RSH=x(2); F = isc-isat*(exp(q*(v+5*i)/N*K*T)-1)-((v+5*i)/RSH)-i; lastly i have the solving function, diodesolve vi = xlsread('vi.xls'); i = vi(:,2); v = vi(:,1); init = [1 100000]; options = optimset('Largescale','off') x=lsqnonlin(@diodemodel,init,[],[],options,i,v); when i run this, the error message i got is: Local minimum possible. lsqnonlin stopped because the relative size of the current step is less than the default value of the step size tolerance. the purpose of my code is to use initeval to calculate the initial variables diodemodel is where the model sits diodesolver is to use lsqnonlin to solve the model and fit the data i am just wondering : have i coded this correctly? what can i do to make it work if the concept is correct? Any help will be appreciated, Sam |