if condition problem programing

2 次查看(过去 30 天)
mado
mado 2013-2-5
i want to do this flow chart but i got obstacle on my way which i pointed to in the picture in this link http://www.mediafire.com/view/?2tkvty7sq9d419o i did this code but it'snot working please help. thanks
if V>Vold %v(k-1)=vold if I==Iold return
elseif I>Iold %I(k-1)=Iold
dvref=Vref+c
else dvref=Vref-c
end
elseif dI==-I/V
return
elseif dI/dV > -I/V
dvref=Vref+c
else
dvref=Vref-c
end
  1 个评论
Jan
Jan 2013-2-5
  1. I do not understand what you are asking for. What is the question?
  2. I cannot see anything useful at the posted link. Most likely I have to play around with the switchs to accept external scripts in my browser, but I do not like to lower my security level only to understand a question. Please contact TMW and ask for a possibility to host pictures on a TMW server.
  3. "It is not working" is not useful. Please explain, if you get an error message (if so, which one) or if the results differ from your expectation (if so, how).

请先登录,再进行评论。

回答(1 个)

mado
mado 2013-2-5
1-the question is how to code this flowchart? 2- mediafire is safe you download the pic safely . 3- not working means that it should give constant value when I=Iold or dI /dV=-I/v but it don't , the output is ramp this code is implemented in embedded matlab function
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 return
elseif I>Iold
dvref=Vref+c
else dvref=Vref-c
end
elseif dI==-I/V
return
elseif dI/dV > -I/V
dvref=Vref+c
else
dvref=Vref-c
end
Iold=I Vold=V Vref=dvref;
  2 个评论
Jan
Jan 2013-2-5
Please do not post this as an answer, when it is a comment to another comment.
mado
mado 2013-2-5
sorry i didn't notice that , i hope that you got my question

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by