embedded matlab function error message
1 回表示 (過去 30 日間)
古いコメントを表示
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
0 件のコメント
回答 (4 件)
Azzi Abdelmalek
2013 年 2 月 8 日
Are you sur one of these two expression
- if V==Vold
- elseif dI/dV~=-I/V
is true for each step?
14 件のコメント
Azzi Abdelmalek
2013 年 2 月 8 日
編集済み: Azzi Abdelmalek
2013 年 2 月 8 日
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
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!