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:
New to Matlab- Need to evaluate 1 eqn in 2 var

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Abdalla Mohamed

Date: 23 Dec, 2008 20:06:03

Message: 1 of 9

Hello there,

I am having a problem evaluating the following equation to get I and V where all the other terms are known.

 I= (i1)-(i2)*exp((V+I)/N)- ((V+I)/M)

Thanks in advance. Regards.

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Roger Stafford

Date: 23 Dec, 2008 20:41:03

Message: 2 of 9

"Abdalla Mohamed" <mangawy_21@hotmail.com> wrote in message <girgbb$j74$1@fred.mathworks.com>...
\> ......
> I am having a problem evaluating the following equation to get I and V where all the other terms are known.
> I= (i1)-(i2)*exp((V+I)/N)- ((V+I)/M)
> .......

  With two unknowns, one equation is not enough to determine them. There are infinitely many combinations of I and V that would satisfy this one equation. I have the feeling this isn't really what you meant. Perhaps you want to find one of them as a function of the other?

Roger Stafford

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Abdalla Mohamed

Date: 23 Dec, 2008 21:01:20

Message: 3 of 9

It's actually an equation to simulate a PV panel output, anyway if it can be solved as one of them as a function of the other, i think it will work out, but can we do that? how it's possible to separate the two variables anyway. Thanks for your help



"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <giricv$1f6$1@fred.mathworks.com>...
> "Abdalla Mohamed" <mangawy_21@hotmail.com> wrote in message <girgbb$j74$1@fred.mathworks.com>...
> \> ......
> > I am having a problem evaluating the following equation to get I and V where all the other terms are known.
> > I= (i1)-(i2)*exp((V+I)/N)- ((V+I)/M)
> > .......
>
> With two unknowns, one equation is not enough to determine them. There are infinitely many combinations of I and V that would satisfy this one equation. I have the feeling this isn't really what you meant. Perhaps you want to find one of them as a function of the other?
>
> Roger Stafford

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Walter Roberson

Date: 23 Dec, 2008 21:44:28

Message: 4 of 9

Abdalla Mohamed wrote:

> I am having a problem evaluating the following equation to get I and V where all the other
> terms are known.
 
> I= (i1)-(i2)*exp((V+I)/N)- ((V+I)/M)

V = -I - I*M + i1*M - N * LambertW(i2*M/N*exp(-M*(I-i1)/N))

Or

I = -V + N * (M*(V+i1)/N/(M+1) - LambertW(-i2*M/(-M*N-N)*exp(M*(V+i1)/N/(M+1))))

Caution: the LambertW function has multiple complex branches

--
.signature note: I am now avoiding replying to unclear or ambiguous postings.
Please review questions before posting them. Be specific. Use examples of what you mean,
of what you don't mean. Specify boundary conditions, and data classes and value
relationships -- what if we scrambled your data or used -Inf, NaN, or complex(rand,rand)?

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Roger Stafford

Date: 23 Dec, 2008 21:49:02

Message: 5 of 9

"Abdalla Mohamed" <mangawy_21@hotmail.com> wrote in message <girjj0$hkc$1@fred.mathworks.com>...
> It's actually an equation to simulate a PV panel output, anyway if it can be solved as one of them as a function of the other, i think it will work out, but can we do that? how it's possible to separate the two variables anyway. Thanks for your help
> .......

  According to my Symbolic Toolbox, the following give V as a function of I and then I as a function of V:

 f = 'I=i1-i2*exp((V+I)/N)-(V+I)/M';
 V = solve(f,'V');
 I = solve(f,'I');

Results:
 V = -(1/N*I+lambertw(exp(-(-i1+I)*M/N) /N*i2*M)-M/N*i1+M/N*I)*N;
 I = -(1/N*V+lambertw(exp(M*(V+i1)/N/(M+1))*i2*M/N/(M+1)) ...
       -M/N/(M+1)*V-M/N/(M+1)*i1)*N;

  You can use the File Exchange version of 'lambertw' at

 http://www.mathworks.com/matlabcentral/fileexchange/6909

for numerical computations of 'lambertw'.

  One note of caution. The LambertW function has more than one branch. There can be two possible real output values for some real values of the input argument and in other cases there may be none. You may have to make use of the "branch" input to tell 'lambertw' which branch you want.

Roger Stafford

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Abdalla Mohamed

Date: 28 Dec, 2008 19:26:02

Message: 6 of 9

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <girmce$df4$1@fred.mathworks.com>...
> "Abdalla Mohamed" <mangawy_21@hotmail.com> wrote in message <girjj0$hkc$1@fred.mathworks.com>...
> > It's actually an equation to simulate a PV panel output, anyway if it can be solved as one of them as a function of the other, i think it will work out, but can we do that? how it's possible to separate the two variables anyway. Thanks for your help
> > .......
>
> According to my Symbolic Toolbox, the following give V as a function of I and then I as a function of V:
>
> f = 'I=i1-i2*exp((V+I)/N)-(V+I)/M';
> V = solve(f,'V');
> I = solve(f,'I');
>
> Results:
> V = -(1/N*I+lambertw(exp(-(-i1+I)*M/N) /N*i2*M)-M/N*i1+M/N*I)*N;
> I = -(1/N*V+lambertw(exp(M*(V+i1)/N/(M+1))*i2*M/N/(M+1)) ...
> -M/N/(M+1)*V-M/N/(M+1)*i1)*N;
>
> You can use the File Exchange version of 'lambertw' at
>
> http://www.mathworks.com/matlabcentral/fileexchange/6909
>
> for numerical computations of 'lambertw'.
>
> One note of caution. The LambertW function has more than one branch. There can be two possible real output values for some real values of the input argument and in other cases there may be none. You may have to make use of the "branch" input to tell 'lambertw' which branch you want.
>
> Roger Stafford

Hey Rogers,

I am still having a problem evaluating this equation using lambertW.
My code is :

Iph=3.8713;
I0=0.00000807307;

f='I= Iph-I0*(exp((V+(I*0.47))/2.5776)-1)-(V+I*0.47)/1365';
V = solve(f,'V');
I= 0:0.2:3.87;
lambertW function was able to put V as a function of I which is good, but i still can't plug in the I values to get the V values. Please help. Is it possible that you provide me with your email ?. Thanks for your time

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Abdalla Mohamed

Date: 29 Dec, 2008 04:38:02

Message: 7 of 9

Hey Rogers,

Please answer my inquiry. i need this solution urgently. i asked for your email address so that i can compensate you for your time if it's possible. Thanks for your help

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Roger Stafford

Date: 29 Dec, 2008 06:33:02

Message: 8 of 9

"Abdalla Mohamed" <mangawy_21@hotmail.com> wrote in message <gj9k7a$t18$1@fred.mathworks.com>...
> ......
> Please answer my inquiry. .....

  In your most recent version I replaced the five constants with symbols:

 f='I=a-b*(exp((V+(I*c))/d)-1)-(V+I*c)/e';

Solving for V as a function of I gives

 V = (a+b)*e-(c+e)*I-d*lambertw(exp(-e/d*(I-b-a))*b*e/d);

This is an explicit formula of V as a function of I. This is about as simple a formula as you are going to find.

  However, when the values of the five constants you have given are substituted in, the argument "-e/d*(I-b-a)" of 'exp' exceeds 2050 for I = 0, which causes the 'exp' output value to become 'inf', meaning that it is too large for matlab's floating point numbers to handle. In other words, with the data values you are using, the problem is seemingly not well-conditioned. Apparently ordinary values for I lead to enormous values for the values being used as lambertw's arguments.

  That is undoubtedly the source of your troubles. It does not appear to be a problem with the LambertW function per se, but rather of the data being sent to it.

Roger Stafford

Subject: New to Matlab- Need to evaluate 1 eqn in 2 var

From: Abdalla Mohamed

Date: 31 Dec, 2008 03:19:02

Message: 9 of 9

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gj9quu$jbu$1@fred.mathworks.com>...
> "Abdalla Mohamed" <mangawy_21@hotmail.com> wrote in message <gj9k7a$t18$1@fred.mathworks.com>...
> > ......
> > Please answer my inquiry. .....
>
> In your most recent version I replaced the five constants with symbols:
>
> f='I=a-b*(exp((V+(I*c))/d)-1)-(V+I*c)/e';
>
> Solving for V as a function of I gives
>
> V = (a+b)*e-(c+e)*I-d*lambertw(exp(-e/d*(I-b-a))*b*e/d);
>
> This is an explicit formula of V as a function of I. This is about as simple a formula as you are going to find.
>
> However, when the values of the five constants you have given are substituted in, the argument "-e/d*(I-b-a)" of 'exp' exceeds 2050 for I = 0, which causes the 'exp' output value to become 'inf', meaning that it is too large for matlab's floating point numbers to handle. In other words, with the data values you are using, the problem is seemingly not well-conditioned. Apparently ordinary values for I lead to enormous values for the values being used as lambertw's arguments.
>
> That is undoubtedly the source of your troubles. It does not appear to be a problem with the LambertW function per se, but rather of the data being sent to it.
>
> Roger Stafford


Hey Rogers,

Thanks for your efforts. I am considering another technique to solve my problem. Happy new year

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