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

Doubt math

Asked by Nuno on 6 Apr 2011

I have the next expression and my unknown is "I".

I = ICC - IR.*(2.718.^((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp);

Exist any function im Matlab that resolve this expression without math methods?

0 Comments

Nuno

Products

No products are associated with this question.

4 Answers

Answer by Matt Tearle on 7 Apr 2011
Accepted answer

OK, to expand on the cyclist's answer:

  1. rewrite your equation in the form f(I) = 0: ICC - IR.*(exp((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp) - I = 0
  2. having defined all the constants (ICC, m, VT, etc), make a function of I using an anonymous function handle: f = @(I) ICC - IR.*(exp((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp) - I;
  3. apply fsolve to f

Like Walter, I'm assuming 2.718.^foo really means e^foo, which, in MATLAB, should be implemented as exp(foo).

13 Comments

Walter Roberson on 11 Apr 2011

No, you can only solve for a single value of V1 if you are using fzero() . You could solve over multiple V1 if you had the optimization toolkit and fsolve() but the setup would change.

If you go back to the symbolic LambertW expression that I showed, then you should be able to vectorize that.

Nuno on 11 Apr 2011

This expression:

-(V1-(-LambertW(-Rs*IR*Rp*exp(Rp*(Rs*ICC+Rs*IR+V1)/(m*VT*(Rp+Rs)))/(-Rs*m*VT-Rp*m*VT))+Rp*(Rs*ICC+Rs*IR+V1)/(m*VT*(Rp+Rs)))*m*VT)/Rs

But, how do you transform the expression in this form?

Walter Roberson on 11 Apr 2011

I used a different symbolic package to get that, but it is likely that solve() like Tim showed should be able to handle it.

Matt Tearle
Answer by Matt Fig on 6 Apr 2011

What do you mean "without math methods?" MATLAB uses only math methods as far as I know...

13 Comments

Nuno on 7 Apr 2011

I mean a numeric answer...

Matt Tearle on 7 Apr 2011

Yeah, we wouldn't want any awkwardly named functions...

**cough CUMTRAPZ cough***

Image Analyst on 12 Oct 2012

Or "ASSEMPDE".

Matt Fig
Answer by the cyclist on 6 Apr 2011

You could use the function "fzero" to solve this equation.

1 Comment

Nuno on 7 Apr 2011

But how fzero resolve this problem?

the cyclist
Answer by Tim Zaman on 6 Apr 2011

I guess what you need is just a solver; for example you define

syms ICC IR V1 Rs m VT Rp;

solve('I = ICC - IR.*(2.718.^((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp)')

-untested-

4 Comments

Walter Roberson on 6 Apr 2011

Symbolically, assuming 2.718 represents exp(1),

-(V1-(-LambertW(-Rs*IR*Rp*exp(Rp*(Rs*ICC+Rs*IR+V1)/(m*VT*(Rp+Rs)))/(-Rs*m*VT-Rp*m*VT))+Rp*(Rs*ICC+Rs*IR+V1)/(m*VT*(Rp+Rs)))*m*VT)/Rs

Ugly. But it is the standard form to solve such equations, which is a fact you would have to know through mathematical experience as the Lambert W function is not one of the obvious ones.

Nuno on 7 Apr 2011

Ups... I don't understand...

Walter Roberson on 7 Apr 2011

"How this works" is that the symbolic solver does pattern matching and determines that the expression matches a pattern that it knows how to solve. It then substitutes the components from your actual expression in to the general solution to the kind of problem that it has decided your expression is. It so happens that the pattern matched is one whose answer is expressed in terms of the Lambert W function. _Why_ the Lambert W function is the answer for those kinds of problems is a topic for a series of lectures in complex analysis.

Tim Zaman

Contact us