DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Calculate individual channel values in absolute terms

Hello,

 

I have a question and I would like to calculate the individual values of a channel line by line.

Here is an example:

 

Line Channel 1 ABS calculated
1 0 0
2 5 5
3 5 0
4 10 5
5 -10 20
6 0 10

 

Row 1 minus row 2 is calculated absolutely, the result in column ABS calculated in row 2 is therefore 5.

The same with row 2 minus row 3, in column ABS calculated in row 3 again the new value 0.

The whole thing continues row by row, of course. In Excel, this would be the classic formula =ABS(A1-A2) and simply copy this down for each additional row. How could I make this possible here in Diadem? I haven't found anything suitable yet. Maybe someone can help me?

Many thanks and best regards

 

0 Kudos
Message 1 of 3
(174 Views)

There are different approaches. You can write a script like that:

 

dim i, objChn

 

set objChn = Data.Root.ChannelGroups(1).Channels

 

Call objChn.Add("Channel 2", DataTypeFloat64)

 

for i = 2 to objChn("Channel 1").Size
  objChn("Channel 2").Values(i) = abs(objChn("Channel 1").Values(i) - objChn("Channel 1").Values(i - 1))
next

 

or use the channel function "calculate differences" and afterwards calculate the absolute value of the result channel using the calculator:

 

ch("[1]/Delta") = abs(ch("[1]/Delta"))

 

 

 

DIAdem experience since 1996

Turn-key applications - Remote and on-site trainings - On-the-job training

| müller+krahmer GmbH | Koenitzer Straße 14, 07338 Kaulsdorf / Germany |
| Phone: +49 36733 / 2328 - 6 | Mobile: +49 160 / 287 7294 |
| Email: mueller@mueller-krahmer.de | Web: www.mueller-krahmer.de |
0 Kudos
Message 2 of 3
(136 Views)

You can write a script:

 

dim i, objChn
set objChn = Data.Root.ChannelGroups(1).Channels
Call objChn.Add("Channel 2", DataTypeFloat64)
for i = 2 to objChn("Channel 1").Size
  objChn("Channel 2").Values(i) = abs(objChn("Channel 1").Values(i) - objChn("Channel 1").Values(i - 1))
next

 

Or you can use the "calculate differences" function in ANALYSIS and the calculate the absolute values using the Calculator:

 

ch("[1]/Delta") = abs(ch("[1]/Delta"))

DIAdem experience since 1996

Turn-key applications - Remote and on-site trainings - On-the-job training

| müller+krahmer GmbH | Koenitzer Straße 14, 07338 Kaulsdorf / Germany |
| Phone: +49 36733 / 2328 - 6 | Mobile: +49 160 / 287 7294 |
| Email: mueller@mueller-krahmer.de | Web: www.mueller-krahmer.de |
0 Kudos
Message 3 of 3
(136 Views)