DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

FormulaCalc with Waveform Channels

I'm using DIADEM 10.0 and observe the following problem:
 
Calling "FormulaCalc" like this in a script:
 
R1=<Some constant != 0>
Call FormulaCalc("Ch('Group/NewChannel):= Ch('Group/WaveformChannel1')-Ch(''Group/WaveformChannel2')/R1")
with "WaveformChannel1" and "WaveformChannel2" being waveform-channels, I expect "NewChannel" to be a waveform-channel, too.
But in some cases the result channel is returned as numeric channel, in some as waveform-channel.
 
Both input-channels have the same "waveform x-offset" (e.g. -0.0169000000000023) and  nearly the same "waveform x-step width"
(e.g. 5.00000000000153E-06 and 4.99999999999996E-06 with the difference resulting from roundoff errors).
Is someone able to explain, what the criteria are to get a waveform channel as result of the calculation?
 
Any help is welcome!
 
Tim
0 Kudos
Message 1 of 3
(3,396 Views)

Hi Tim,

You've pretty much diagnosed the situation.  If you manually change the "Waveform x-step width" property for both waveform channels in the Data Portal to the average of their two values (5E-06) so that they both have identical waveform properties, the FormulaCalc() operation will product a new waveform channel.  If either the waveform time offset or waveform delta time properties are even slightly different, the resulting channel is a numeric channel.

Ask if you have questions about setting the property,
Brad Turpin
DIAdem Product Support Engineer
National Instruments

0 Kudos
Message 2 of 3
(3,359 Views)

Hi Tim,

Let me add one comment to Brad's explanation:

You can test the "equality" of two floating point numbers in the following way:

Call FormulaCalc("B1 := 5.00000000000153E-06 = 4.99999999999996E-06")
Call MsgBox(B1) ' false
Call FormulaCalc("B1 := 5.000000000000153E-06 = 4.99999999999996E-06")
Call MsgBox(B1) ' true

' DIAdem 10.1 or higher
If ProgramRevision >= 1010 Then
  Call MsgBox(ValEqual(5.00000000000153E-06, 4.99999999999996E-06)) ' false
  Call MsgBox(ValEqual(5.000000000000153E-06, 4.99999999999996E-06)) ' true
End If

You will see that DIAdem uses approx. 13 significant figures for the comparism.

Christian

0 Kudos
Message 3 of 3
(3,345 Views)