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?

 채택된 답변

Matt Tearle
Matt Tearle 2011년 4월 7일

0 개 추천

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

Nuno
Nuno 2011년 4월 7일
But this expression: f(I) = 0: ICC - IR.*(exp((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp) - I = 0, is not valid...
Walter Roberson
Walter Roberson 2011년 4월 7일
That "rewrite your equation" is intended in a mathematical sense. The MATLAB implementation is as shown by Matt in step 2.
Nuno
Nuno 2011년 4월 7일
Ok...
Then i write:
f = @(I);
f=ICC - IR.*(exp((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp) - I;
f = fsolve(I);
is this?
Matt Tearle
Matt Tearle 2011년 4월 7일
No, use the exact code I gave in step 2 to define f:
f = @(I) ICC - IR.*(exp((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp) - I;
This creates f as an anonymous function handle, so f is a function of the dummy variable I. Everything else in that expression is a variable that has already been defined.
Nuno
Nuno 2011년 4월 8일
In this form?
f = @(I) ICC - IR.*(exp((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp) - I;
I = fsolve(@(I));
Don´t works...
Walter Roberson
Walter Roberson 2011년 4월 8일
No, fsolve(f)
Nuno
Nuno 2011년 4월 8일
With fsolve(f) don't works :(
Walter Roberson
Walter Roberson 2011년 4월 8일
Do you have the optimization toolbox that defines fsolve() ? If not, then
fzero(f,-10)
The answer does not vary with initial starting point.
Matt Tearle
Matt Tearle 2011년 4월 8일
which fsolve
If you have it, then I = fsolve(f,I0) where I0 is an initial guess (such as -10, like Walter showed).
If not, then I = fzero(f,I0) (again, as Walter showed).
Nuno
Nuno 2011년 4월 11일
If V1 vary (in this case V1=0:1:32) the expression is the same?
Walter Roberson
Walter Roberson 2011년 4월 11일
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
Nuno 2011년 4월 11일
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
Walter Roberson 2011년 4월 11일
I used a different symbolic package to get that, but it is likely that solve() like Tim showed should be able to handle it.

댓글을 달려면 로그인하십시오.

추가 답변 (4개)

Matt Fig
Matt Fig 2011년 4월 6일

2 개 추천

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

댓글 수: 14

Tim Zaman
Tim Zaman 2011년 4월 6일
he just wants the "I" out of the middle and last part of the equation singled out.
Matt Fig
Matt Fig 2011년 4월 6일
Perhaps...
Nuno
Nuno 2011년 4월 6일
Yes Tim Zaman ...
Matt Tearle
Matt Tearle 2011년 4월 6일
Matt, it's a dirty little secret that MATLAB was actually written by astrologers with ouija boards. fzero works by summoning demons from the Fourth Circle.
OK, seriously, Nuno, do you mean you want a symbolic answer (ie "rearrange the equation to get I = expression in terms of V1, etc")? Or perhaps a numeric answer ("for a given set of values for V1, IR, etc, I = 0.626782")?
Sean de Wolski
Sean de Wolski 2011년 4월 6일
@Matt T, if fzero summons demons; does bsxfun summon oompa-lumpas to perform the operations?
Matt Fig
Matt Fig 2011년 4월 6일
@Sean de, BSXFUN simply is the Fourth Circle.
Matt Tearle
Matt Tearle 2011년 4월 7일
Oompa Loompa doompety doo
We have a binary expansion for you
Oompa Loompa doompety dee
It has squat to do with binary
Matt Fig
Matt Fig 2011년 4월 7일
They had to come up with something, because SXFUN looks too much like sucks-fun - hardly a good name for a built-in function!
the cyclist
the cyclist 2011년 4월 7일
That's not the first thing that sprang to mind when I saw SXFUN.
Matt Fig
Matt Fig 2011년 4월 7일
That remark made me laugh out loud, cyclist! Too funny.
Nuno
Nuno 2011년 4월 7일
I mean a numeric answer...
Matt Tearle
Matt Tearle 2011년 4월 7일
Yeah, we wouldn't want any awkwardly named functions...
**cough CUMTRAPZ cough***
Image Analyst
Image Analyst 2012년 10월 12일
Or "ASSEMPDE".
Image Analyst
Image Analyst 2015년 10월 15일
A new funny one is "removecats" (in the Statistics and Machine Learning Toolbox). People have been trying to use it on youtube and Facebook videos.

댓글을 달려면 로그인하십시오.

the cyclist
the cyclist 2011년 4월 6일

0 개 추천

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

댓글 수: 1

Nuno
Nuno 2011년 4월 7일
But how fzero resolve this problem?

댓글을 달려면 로그인하십시오.

Tim Zaman
Tim Zaman 2011년 4월 6일

0 개 추천

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

Nuno
Nuno 2011년 4월 6일
But, how this works?
Walter Roberson
Walter Roberson 2011년 4월 6일
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
Nuno 2011년 4월 7일
Ups... I don't understand...
Walter Roberson
Walter Roberson 2011년 4월 7일
"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.

댓글을 달려면 로그인하십시오.

Jenna
Jenna 2023년 2월 23일
편집: Jenna 2023년 2월 23일

0 개 추천

Unfortunately, there is no built-in MATLAB function that can solve an equation like the one you have given without using any mathematical methods. However, MATLAB does have functions that can help you solve equations numerically using methods like Newton-Raphson or the Bisection method.
Here's an example of how you could use the fsolve function in MATLAB to solve your equation:
% Define the function you want to solve
fun = @(I) ICC - IR.*(2.718.^((V1+Rs*I)./(m.*VT))-1) - ((V1+Rs.*I)/Rp);
% Use fsolve to find the value of I that solves the equation
I = fsolve(fun, x0);
% Display the result
disp(['The value of I that solves the equation is ', num2str(I)]);
In this example, x0 is an initial guess for the value of I. You would need to define the values of ICC, IR, V1, Rs, m, VT, and Rp beforehand.

카테고리

도움말 센터File Exchange에서 Symbolic Math Toolbox에 대해 자세히 알아보기

질문:

2011년 4월 6일

편집:

2023년 2월 23일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by