Sep-29-2016, 09:21 AM
Dear all, Good morning from Germany,
I have a python code in which the function returns two values. Out of which, only one value changes at a time and other remains the same. I want to find which is changing and want to append it. The code looks as following
I have a python code in which the function returns two values. Out of which, only one value changes at a time and other remains the same. I want to find which is changing and want to append it. The code looks as following
def calcrand(self,xlowrand,xhighrand):
xalg = self.xalg
yalg = self.yalg
xlowrand = self.xlowrand
xhighrand = self.xhighrand
if (len(xalg))>=2 and len(yalg)>=2:
last = len(yalg)-1
xPrevious = xalg[last-1]
xLast = xalg[last]
yPrevious = yalg[last-1]
yLast = yalg[last]
prevdist= abs(yalg[last-1]-ygoal)
currentdist= abs(yalg[last]-ygoal)
if currentdist<prevdist:
m=float ((yLast-yPrevious)/(xLast-xPrevious))
if m>0:
if yalg[last]< ygoal:
xlowrand=xalg[last]
return float(xlowrand),float(xhighrand),
else:
xhighrand=xalg[last]
return float(xlowrand),float(xhighrand)
elif yalg[last]< ygoal:
xhighrand=xalg[last]
return float(xlowrand),float(xhighrand)
else:
xlowrand=xalg[last]
return float(xlowrand),float(xhighrand)
elif (len(xalg))==1:
return float(xlowrand),float(xhighrand)
elif (len(xalg))<1:
return float(xlowrand),float(xhighrand)
else:
print('there are no data')
return float(xlowrand),float(xhighrand)I run this in a loop...
