Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Fitting Implicit Nonlinear Functions

Subject: Fitting Implicit Nonlinear Functions

From: Ryan Need

Date: 22 Jun, 2010 19:33:24

Message: 1 of 3

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

Subject: Fitting Implicit Nonlinear Functions

From: Miroslav Balda

Date: 22 Jun, 2010 20:53:05

Message: 2 of 3

"Ryan Need" <rneed@clemson.edu> wrote in message <hvr364$e4l$1@fred.mathworks.com>...
Hi,
Could you supply measured V and I vectors and displayed error messages?
Mira

Subject: Fitting Implicit Nonlinear Functions

From: sam ng

Date: 20 Jul, 2010 12:34:04

Message: 3 of 3

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <hvr7rh$nqs$1@fred.mathworks.com>...
> "Ryan Need" <rneed@clemson.edu> wrote in message <hvr364$e4l$1@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

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us