Effacer les filtres
Effacer les filtres

embedded matlab function error message

1 vue (au cours des 30 derniers jours)
mado
mado le 8 Fév 2013
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/dV~=-I/V
if dI/dV > -I/V
dvref=Vref-c
else
dvref=Vref+c
end
end
Iold=I
Vold=V

Réponses (4)

Walter Roberson
Walter Roberson le 8 Fév 2013
In your "if I~=Iold" case you do not assign anything to dvref .
  1 commentaire
mado
mado le 8 Fév 2013
actually this is not the problem i tried it but in a vain , error is still there.

Connectez-vous pour commenter.


mado
mado le 8 Fév 2013
the answer is that dvref should be outside the if condition but in my flowchart it'snot outside the if condition ,so i don't know how to implement it any one help

Azzi Abdelmalek
Azzi Abdelmalek le 8 Fév 2013
Are you sur one of these two expression
  • if V==Vold
  • elseif dI/dV~=-I/V
is true for each step?
  14 commentaires
mado
mado le 8 Fév 2013
dvref can't be declared on persistent as it is the output of the embedded function.
Azzi Abdelmalek
Azzi Abdelmalek le 8 Fév 2013
Modifié(e) : Azzi Abdelmalek le 8 Fév 2013
You can use a unit delay block to get the previous value of dvref. Name it dvref_old, then in your code instead of "Doing nothing" you will do:
dvref=dvref_old

Connectez-vous pour commenter.


mado
mado le 8 Fév 2013
if I-Iold=0 if yes return if no check the next step i don't know "return" here is right or not, so i reversed it i checked the inequality and so on
  2 commentaires
Walter Roberson
Walter Roberson le 8 Fév 2013
You cannot just return without having assigned something to dvref .
mado
mado le 9 Fév 2013
ok , how to do this using simulink i think it will be easier

Connectez-vous pour commenter.

Catégories

En savoir plus sur Configure and View Diagnostics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by