02-11-2016 11:51 AM
Is there a way to make simple calculations (addition/subtraction) of selected single values within channels? Very new DIAdem user, so I'm not familiar with scripts at all. Seems like it should be an easy command, and I'm just overlooking it.
Thank You,
Shannon
Solved! Go to Solution.
02-12-2016 09:32 AM
Hey Shannon,
You can do something like this:
Set oMyChannel1 = Data.Root.ActiveChannelGroup.Channels(1)
Set oMyChannel2 = Data.Root.ActiveChannelGroup.Channels(2)
oMyAddition = oMyChannel1.Values(1) + oMyChannel2.Values(1)
You could also replace the last line with:
oMyAddition = oMyChannel1(1) + oMyChannel2(1)
02-12-2016 11:27 AM
Hello Shannon,
It sounds to me like you would like to add two or more "cells" (to use Excel lingo) together.
DIAdem manages data as channels, not individual cells. So the approach to add two cells in DIAdem works like this:
The ChD variable allows you to access a single "cell" in a channel, using the following sequence or parameters:
ChD(X,Y)
where X is the row number of the channel table, and Y is the channel (column) name or number of the cell you wish to access.
So, this expression here calculates the result of adding the 2nd row value of the channel called "Temperature_1" and the channel called "Temperature_2" from the example data set that loads when DIAdem is started. R1 in this case is an internal DIAdem real variable that stores a single value.
R1 = ChD(2,Ch("[4]/Temperature_1")) + ChD(2,Ch("[4]/Temperature_2"))
The calculation above can be entered in the "Calculator" which is available in DIAdem VIEW and in DIAdem ANALYSIS in the toolbar.
I hope this is helpful, please let us know if you have additional questions,
Otmar
02-12-2016 11:42 AM
Thank you Otmar...this is most helpful!!
Now, my question is... how do I get my 'R' values onto my reports? I'm having trouble figuring out how to do that.
Thank you!
02-12-2016 11:43 AM
Thank you Britton C! Your reply was very helpful.
02-12-2016 12:19 PM
Hello Shannon,
There are multiple ways to do that, including putting the results of your calculations into a new channel (for a table for instance), or simply by putting the calculation or the variable reference into a text, see these two attached examples (they are both in the same text window):
As you can see, you can even do the calculation right inside the text, or just reference the variable containing your results.
The @@ tells DIAdem that you are referencing a variable (or variables in the first case) and want to see the contents of these variable(s).
If you have an example of what your final goal is for a report (i.e. a table of values, a constant line in an axis system at a specific value, etc.) I can create a more specific example, but this is the general way how you can include calculated values and variables inside a report.
Otmar
02-12-2016 12:59 PM
Otmar,
This is so helpful! I know how to do what I need now. If I have any further questions, I'll be sure to reply!
Thank you SO MUCH!
Shannon H.
04-04-2018 01:55 PM
how would i do this same thing, but within a graph? I want to pick specific values out of channels, and not just graph an entire channel.
04-04-2018 02:20 PM
Hi Derek,
I do'nt understand your question, or at least it seems to me that picking values out of channels is exactly what is described in this topic. Can you be more specific please ? Maybe with a screenshot explaining what you want to achieve ?
Thanks,
04-04-2018 02:33 PM
the examples above only seem to work when doing calculations, or if you do it in a text box. If you try to use this method within a graph (as seen in attached picture), it doesn't work.