Path: news.mathworks.com!not-for-mail
From: "mado " <elec_mnf@yahoo.com>
Newsgroups: comp.soft-sys.matlab
Subject: algebraic loop error
Date: Fri, 30 Nov 2012 17:46:08 +0000 (UTC)
Organization: NWRC
Lines: 22
Message-ID: <k9ard0$l76$1@newscl01ah.mathworks.com>
Reply-To: "mado " <elec_mnf@yahoo.com>
NNTP-Posting-Host: www-04-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1354297568 21734 172.30.248.35 (30 Nov 2012 17:46:08 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 30 Nov 2012 17:46:08 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1841640
Xref: news.mathworks.com comp.soft-sys.matlab:783864

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)"