06-08-2010 08:50 AM
Hi, I would like to convert formula in the below to labview format, any idea how this could be done easiest way?
I'm planning to use formula node but I'm not not sure about how to use lookup table inside the formula or is it even possible?
br, Jani
Dim dblLookUp(,) As Double = New Double(3, 1) {{4, 4}, {10, 200}, {60, 3000}, {100, 7000}}
If dblAbsValue >= 0 And dblAbsValue <= dblLookUp(0, 0) Then
dblk = dblLookUp(0, 1) / dblLookUp(0, 0)
dblValue = dblAbsValue * dblk
'lblMode.Text = 1
ElseIf dblAbsValue > dblLookUp(0, 0) And dblAbsValue <= dblLookUp(1, 0) Then
dblk = (dblLookUp(1, 1) - dblLookUp(0, 1)) / (dblLookUp(1, 0) - dblLookUp(0, 0))
dblValue = dblk * dblAbsValue - dblk * dblLookUp(0, 0) + dblLookUp(0, 1)
'lblMode.Text = 2
ElseIf dblAbsValue > dblLookUp(1, 0) And dblAbsValue <= dblLookUp(2, 0) Then
dblk = (dblLookUp(2, 1) - dblLookUp(1, 1)) / (dblLookUp(2, 0) - dblLookUp(1, 0))
dblValue = dblk * dblAbsValue - dblk * dblLookUp(1, 0) + dblLookUp(1, 1)
'lblMode.Text = 3
ElseIf dblAbsValue > dblLookUp(2, 0) And dblAbsValue <= dblLookUp(3, 0) Then
dblk = (dblLookUp(3, 1) - dblLookUp(2, 1)) / (dblLookUp(3, 0) - dblLookUp(2, 0))
dblValue = dblk * dblAbsValue - dblk * dblLookUp(2, 0) + dblLookUp(2, 1)
'lblMode.Text = 4
Else
dblValue = dblLookUp(3, 1) '* Math.Sign(dblValue)
'lblMode.Text = 5
End If
Return dblValue * intSign
Solved! Go to Solution.
06-08-2010 11:07 AM
Hello janijt,
You can definitely use formula node for it. What you would do is to create a constant array for the lookup table.
Here's an implementation in MathScript Node
06-09-2010 01:09 AM
Thanks for help!
br, Jani
06-09-2010 01:33 AM
06-09-2010 02:48 AM
Hi GerdW
No it does not, but I thinkthat formula node is easiest way to do it because calculation is not time critical.
br, Jani