Thread Subject:
algebraic loop error

Subject: algebraic loop error

From: mado

Date: 30 Nov, 2012 17:46:08

Message: 1 of 7

when using Ipold= Ip in this embedded function code

function [e,Pm,Ip] = new(In,Vn)
persistent Ipold ;
if isempty(Ipold)
   Ipold=2; %initialized only once in the beginning
end
K1=2;
K2=-.195;
Pn= Vn*In
Pm=100*In
e= Pn-Pm
if Pn>Pm
Ip = Ipold+K1 *e
end
Ip = Ipold+K2 *e
Ipold=Ip



error message appeared
"Trouble solving algebraic loop containing 'chee_pv/pv6/Algebraic Constraint/Initial Guess' at time 0. Stopping simulation. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)"

Subject: algebraic loop error

From: Roger Stafford

Date: 30 Nov, 2012 20:32:08

Message: 2 of 7

"mado " <elec_mnf@yahoo.com> wrote in message <k9ard0$l76$1@newscl01ah.mathworks.com>...
> if Pn>Pm
> Ip = Ipold+K1 *e
> end
> Ip = Ipold+K2 *e
- - - - - - - - - -
  There is something amiss in your code. The 'if-end' result is totally ignored:

 if Pn>Pm
  Ip = Ipold+K1 *e
 end
 Ip = Ipold+K2 *e

Regardless of whether Pn is greater than Pm or not, the result is always the same. The line "Ip = Ipold+K2*e" overwrites whatever change was made to 'Ip' in the 'if' construct. I am sure you meant something else.

Roger Stafford

Subject: algebraic loop error

From: mado

Date: 30 Nov, 2012 22:21:07

Message: 3 of 7

.

error message came even if i correct the if condition to

 if Pn>Pm
  Ip = Ipold+K1 *e
else
Ip = Ipold+K2 *e
 end
but this time with this line Ipold =Ip or without .

Subject: algebraic loop error

From: mado

Date: 1 Dec, 2012 12:26:08

Message: 4 of 7

"mado " <elec_mnf@yahoo.com> wrote in message <k9bbgj$er1$1@newscl01ah.mathworks.com>...
> .
>
> error message came even if i correct the if condition to
>
> if Pn>Pm
> Ip = Ipold+K1 *e
> else
> Ip = Ipold+K2 *e
> end
> but this time with this line Ipold =Ip or without .

Subject: algebraic loop error

From: mado

Date: 2 Dec, 2012 19:03:07

Message: 5 of 7

any suggestion please??

Subject: algebraic loop error

From: Roger Stafford

Date: 2 Dec, 2012 19:35:08

Message: 6 of 7

"mado " <elec_mnf@yahoo.com> wrote in message <k9ard0$l76$1@newscl01ah.mathworks.com>...
> "Trouble solving algebraic loop containing 'chee_pv/pv6/Algebraic Constraint/Initial Guess' at time 0. Stopping simulation. There may be a singularity in the solution. If the model is correct, try reducing the step size (either by reducing the fixed step size or by tightening the error tolerances)"
- - - - - - - - -
  It looks as though this error message is associated with the way you are using 'new' rather than being about 'new' itself. Are you using Simulink? If I were you, I would read that message very carefully and see if it contains a clue as what the trouble is. It seems to hint that some iteration you have set up, presumably involving 'new', is not converging properly.

Roger Stafford

Subject: algebraic loop error

From: mado

Date: 3 Dec, 2012 07:45:09

Message: 7 of 7

what is "new" do you mean ???
yes its simulink, and this code is included in embedded matlab function

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us