Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


dpb
Posts:
9,242
Registered:
6/7/07


Re: if condition problem
Posted:
Feb 5, 2013 9:50 AM


On 2/5/2013 2:44 AM, mado wrote: > 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(k1)=vold > if I==Iold > return elseif I>Iold %I(k1)=Iold > dvref=Vref+c > else dvref=Vrefc end > elseif dI==I/V > return > elseif dI/dV > I/V > dvref=Vref+c > else dvref=Vrefc > end
A) What, specifically, is "not working"? Input, expected output and result obtained...
B) What are the variables? Particularly if they're arrays/vectors rather than simple variables then be aware of the Matlab definition of logical comparisonsa logical operation on a vector/array returns a logical vector/array of the same size and a comparison is T iff all values in that vector/array are T.
C) Remember floating point comparisons for exactly == are fraught w/ the problem of precisionmuch better will be to use a tolerance or recast so the exactly equal "==" test isn't performed explicitly.
D) As a stylistic choice you might consider CASE constructs...
doc isequal




