05-07-2013 02:24 PM - edited 05-07-2013 02:25 PM
Hello. I am using the calculator to create a new channel that is a custom filtered version of an existing channel. Unfortunately, I have not been able to identify the previous row entry in the channel. To make things easier, let's say my filter is a simple averager. Here is simple pseudocode for what I want to do:
New_Channel = (Existing_Channel[n] + Existing_Channel[n-1]) / 2
where n is the current row.
This is the calculator formula I have come up with:
ch("[1]/New_Channel") = (CHD(chnRow - 1, "[1]/Existing_Channel") + ch("[1]/Existing_Channel")) / 2 + CTNV(chnRow > 1)
Unfortunately, I think chnRow only returns 0.
Obviously, I am a beginner. I am open to other approaches to creating a new channel with a custom filter.
Thanks!
Solved! Go to Solution.
05-08-2013 07:11 AM
Hi jbuttron,
What you need to do is to copy the channel and delete the first value from the copied channel-- then the Nth row of the original channel will line up with the (N-1)th row of the copied channel. You should also add the last value of the copied channel to the end of that channel as a new value so both channels end up with the same channel length. Now you can reference the channels with Ch("[1]/old") and Ch("[1]/new") in the channel calculator expression, assuming that the channel names are "old" and "new" respectively and that both are in the first group. You don't need a row variable in the expression now, which is good because there's no way to iterate a row variable in a channel calculator expression. The row iteration is implicit in the channel referencing Ch("[1]/new").
Brad Turpin
DIAdem Product Support Engineer
National Instruments
05-08-2013 08:51 AM
Great solution. Simple. Thanks!