Date: Feb 8, 2013 12:12 PM
Author: mado
Subject: embedded matlab function error

i have this error message "Output argument 'dvref' is not assigned on some execution paths."
when executing this code
function dvref =IC(V,I)

persistent Vref Vold Iold c;
if isempty(Vold)
Vold=0; %initialized only once in the beginning
end
if isempty(Iold)
Iold=0; %initialized only once in the beginning
end
if isempty(c)
c = .1; %initialized only once in the beginning
end
if isempty(Vref)
Vref=.5; %initialized only once in the beginning
end

dI=I-Iold;
dV=V-Vold;

if V==Vold
if I~=Iold

elseif I>Iold
dvref=Vref-c
else dvref=Vref+c
end
elseif dI~=-I/V

if dI/dV > -I/V
dvref=Vref-c
else
dvref=Vref+c
end
end

Iold=I
Vold=V