11-22-2024 10:12 AM
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
11-26-2024 10:38 AM
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"))
11-26-2024 10:49 AM
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"))