DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Round every item in a channel

Hello,

I have a bunch of groups with a Column called "Angle" and each of these have about 2000 items. My issue is that each of these has 8 decimal points, but I want none. I'm planning on using the Round() function to just round all these to an integer, but am not sure the best way to do this. Is there a way I can do something like:

 

For item in Range(Length("[group index]/Angle")):

  "[group index]/Angle/[i]" = Round("[group index]/Angle/[i]"

 

So for each element in the Angle channel it will replace it with a rounded number?

0 Kudos
Message 1 of 3
(2,876 Views)

Calculate can be used to assign a method to each value of a channel

Call Calculate("ch(""[1]/Speed"")=int(ch(""[1]/Speed""))")

If you want to loop over all groups the following example might help building a solution

Option Explicit

dim grpO : for each grpO in data.Root.ChannelGroups
  if grpO.Channels.Exists("Speed") then
    dim chO : set cho = grpO.Channels("Speed")
    dim chRef : chRef = chO.GetReference(eRefTypeIndexIndex)
    Call Calculate("ch("""& chRef & """)=int(ch(""" & chRef & """))")    
  end if
Next
Message 2 of 3
(2,848 Views)

Hi Strange,

 

If you have a modern version of DIAdem, you will find a "Rounding" function in the "Basic Mathematics" palette of the ANALYSIS panel. 

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

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