DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

diadem select time cells in time channel with given time increment (cell index)

Hello,

 

I may have a question for scripting.

 

I would like to select cells (Chn_time lines) separated by a given number of cells (time increment, i.ei Step here 1) stored in a new channel (Chn1).

I can do the following:

 

Chn_time = Data.Root.ChannelGroups("time").Channels("time").Properties("name").Value
Chn1 = Data.Root.ChannelGroups("time").Channels("time").Properties("number").Value
  counter=0
  For j = 2 to ChLen Step 1    'loop over cells of channel
    counter=counter+1
    CHD(counter,Chn1) =CHD(j,Chn_time)
  Next

 

But this is not optimal (too lenghty over crazy data)?

 

That would be of great help for me.

 

Thank you very much,

 

Louval

 

0 Kudos
Message 1 of 13
(6,181 Views)

Hi louval,

 

I'm afraid I'm not understanding your goal with your request or with the code you provided.  Why do you reference the same channel twice, once with the channel number and once with the channel name?  Why are you overwriting that time channels values with it's own values from one row further down?

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 2 of 13
(6,141 Views)

OK, so please let me reformulate.

 

What I want to do is simple: select lines every 'n' lines of channel (Chn_time) and copy them in a new channel (Chn_time_cut).

 

The correct version of the code I like to optimize (with data.tdm loaded) reads:

 

Dim counter, Chlen,Chn_time,Chn_time_cut, Grp1,j

  ChLen = Data.Root.ChannelGroups("data").Channels("time").Properties("length").Value
  Chn_time = Data.Root.ChannelGroups("data").Channels("time").Properties("numBer").Value
 
  Call ChnAlloc("t_cut", ChLen,1,,,1)
 
  Chn_time_cut = Data.Root.ChannelGroups("data").Channels("t_cut").Properties("number").Value
  counter=0
  For j = 2 to ChLen Step 1    'loop over cells of channel
    counter=counter+1
    CHD(counter,Chn_time_cut) =CHD(j,Chn_time)
  Next
 
Cheers,

 

Louval

0 Kudos
Message 3 of 13
(6,128 Views)

Hi,

If am I right, you want to copy channels?

If yes, use ChnCopy command:

Call ChnCopyExt("[1]/Chn_time",1,4).

 

Hope this helps!

 

Simyfren

0 Kudos
Message 4 of 13
(6,121 Views)

It would too easy...

I do not want all the lines but only one every n line....

 

Louval

 

0 Kudos
Message 5 of 13
(6,114 Views)

OK, and what problem do you have now?

 

Simyfren

0 Kudos
Message 6 of 13
(6,111 Views)

Just Divide the length of the vector for the number of values that you want. Do the changes in Bold and it should be working, just Dim n and declare how many points of the original channel you want.

 

 

Dim counter, Chlen,Chn_time,Chn_time_cut, Grp1,j

  ChLen = Data.Root.ChannelGroups("data").Channels("time").Properties("length").Value
  Chn_time = Data.Root.ChannelGroups("data").Channels("time").Properties("numBer").Value

  n = "number of steps"


  Call ChnAlloc("t_cut", ChLen,1,,,1)
 
  Chn_time_cut = Data.Root.ChannelGroups("data").Channels("t_cut").Properties("number").Value
  counter=0
  For j = 2 to ChLen/n Step 1    'loop over cells of channel
    counter=counter+1
    CHD(counter,Chn_time_cut) =CHD(j*n,Chn_time)
  Next

0 Kudos
Message 7 of 13
(6,105 Views)

If I do Call ChnCopyExt("[1]/Chn_time",1,4) I get all the line from Chn_time.

 

I do not want all the line, but one every n line with n=4 for instance.

 

Thank you,

 

Louval

0 Kudos
Message 8 of 13
(6,103 Views)

However this will not give you a equidistant channel. Use "ChnLinGen" function instead.

0 Kudos
Message 9 of 13
(6,101 Views)

well this is equivalent as setting:

 

For j = 2 to ChLen Step n    'loop over cells of channel

 

I would like to avoid using a loop to do it. But maybe this is the only way...

 

Louval

0 Kudos
Message 10 of 13
(6,095 Views)