DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Applying rounding function to entire channel

Solved!
Go to solution

I have a channel in DIAdem with a large amount of values (36,000,000)  the values contain about 13 decimal places.

I would like to round the value off to about 4 or 5 decimal places max.  

 

Can someone help me figure out how to do this in DIAdem.

 

Example:

0.3784729837492 ->0.37847 

 

I want do do this for every value in the channel. 

 

can someone help me figure out how to do this? 

 

Thanks in advance,

Tom 

0 Kudos
Message 1 of 5
(5,425 Views)

Hi Tom,

 

You can utilize the VBScript function, Round(value, number of decimal places).  I wrote a quick script in DIAdem which performs this operation on a numeric channel, named dataChannel, and transfers the truncated values a new channel, named truncChannel.

 

Dim toBeTrunc, i

For i = 1 To Data.Root.ChannelGroups(1).Channels("dataChannel").Properties("length").Value
     toBeTrunc = Data.Root.ChannelGroups(1).Channels("dataChannel").Values(i)
     Data.Root.ChannelGroups(1).Channels("truncChannel").Values(i) = Round(toBeTrunc,3)
Next

 

I hope this helps.

 

Warm Regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 2 of 5
(5,393 Views)
Solution
Accepted by topic author TomFerraro

D-cubed's method will work, but with 36,000,000 data points, it will take a long time.  Use the calculator.  Copy this function into the calculator under analysis, and it will occur just about instantaneously.  Replace the 3 with the desired number of decimal places.  

 

Ch("[1]/Channel")=Round(Ch("[1]/ChannelToBeRounded"),3)

 

 

If you need a VB Script:

Dim ChannelToRound, DecimalPoints

ChanneltoRound="[1]/ChannelToBeRounded"  'Put the channel you want to round here
DecimalPoints=6             'Specify the number of decimal points

'This will create a new channel called "Channel" in group 1 with the rounded values
Call Calculate("Ch(""[1]/Channel"")=Round(Ch(""" & ChannelToRound & """)," & DecimalPoints & ")",NULL,NULL,"") '... CalculateFormula,CalculateSymbols,CalculateValues,CalculateTargetUnit 

 

Message 3 of 5
(5,384 Views)

Hi RSenior,

 

Thanks for your post!  Your approach is definitely more efficient.

 

Regards,

Daniel Dorroh
National Instruments
0 Kudos
Message 4 of 5
(5,367 Views)

Thanks everyone for all your help, I really appreciate it. 

0 Kudos
Message 5 of 5
(5,360 Views)