Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

if condition problem programing

Asked by mado on 5 Feb 2013

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 Comment

Jan Simon on 5 Feb 2013
  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).
mado

Products

No products are associated with this question.

1 Answer

Answer by mado on 5 Feb 2013

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 Comments

Jan Simon on 5 Feb 2013

Please do not post this as an answer, when it is a comment to another comment.

mado on 5 Feb 2013

sorry i didn't notice that , i hope that you got my question

mado

Contact us