MATLAB Answers

## Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.

Asked by Marios Karatiso

### Marios Karatiso (view profile)

on 15 Apr 2019
Latest activity Commented on by Marios Karatiso

### Marios Karatiso (view profile)

on 15 Apr 2019
Accepted Answer by madhan ravi

### madhan ravi (view profile)

Hello, I get the following error when trying to use fsolve:
Error in fsolve (line 218)
fuser = feval(funfcn{3},x,varargin{:});
Caused by:
Failure in initial user-supplied objective function evaluation. FSOLVE cannot continue.
It also prints the following error: Index exceeds matrix dimensions.
Can anyone see where is the error in that situation?
I call the fsolve with that line of code:
sol=fsolve(@set,[1;-1])
The function is the following:
function F=set(x)
Vcc=15;
Rth=(100/3)*10^3;
Re=10*10^3;
Rc=20*10^3;
beta_f=100;
beta_R=1;
Is=5*10^(-16);
Vt=0.025;
Voc=10;
F=[x(1)-(-Rth-Re(beta_f+1))*(Is/beta_f)*(exp(x(1)/Vt)-1)-(-Rth+beta_R*Re)*(Is/beta_f)*(exp(x(2)/Vt)-1)+Voc;
x(2)-(-Rth+Rc*beta_f)*(Is/beta_f)*(exp(x(1)/Vt)-1)-(-Rth-Rc*(beta_R+1))*(Is/beta_f)*(exp(x(2)/Vt)-1)-Vcc+Voc];
end

#### 0 Comments

Sign in to comment.

## 1 Answer

Answer by madhan ravi

### madhan ravi (view profile)

on 15 Apr 2019
Edited by madhan ravi

### madhan ravi (view profile)

on 15 Apr 2019
Accepted Answer

Note: Don't name your function set() will shadow the in-built function set().
sol=fsolve(@set1,[1,-1])
function F=set1(x)
Vcc=15;
Rth=(100/3)*10^3;
Re=10*10^3;
Rc=20*10^3;
beta_f=100;
beta_R=1;
Is=5*10^(-16);
Vt=0.025;
Voc=10;
F=[x(1)-(-Rth-Re*(beta_f+1))*(Is/beta_f)*(exp(x(1)/Vt)-1)-(-Rth+beta_R*Re)*(Is/beta_f)*(exp(x(2)/Vt)-1)+Voc;
% ^----- missed it
x(2)-(-Rth+Rc*beta_f)*(Is/beta_f)*(exp(x(1)/Vt)-1)-(-Rth-Rc*(beta_R+1))*(Is/beta_f)*(exp(x(2)/Vt)-1)-Vcc+Voc];
end
Gives:
Equation solved.
fsolve completed because the vector of function values is near zero
as measured by the default value of the function tolerance, and
the problem appears regular as measured by the gradient.
<stopping criteria details>
sol =
-11.3516
0.7520
>>

Marios Karatiso

### Marios Karatiso (view profile)

on 15 Apr 2019
Sorry the 1 in @set1 was a typo.
Marios Karatiso

### Marios Karatiso (view profile)

on 15 Apr 2019
Oh that was such a bad mistake thanks a lot...

Sign in to comment.