03-24-2011 01:56 PM
How do you perform the "average" function in analysis using only one channel? Currently I must do this by hand in the .csv file that I import to Diadem. I'd prefer not to do this because of scripting.
Solved! Go to Solution.
03-25-2011 08:30 AM - edited 03-25-2011 08:30 AM
Hi shredderjohn,
First of all, is that a Bloom County reference (Cutter John)? The first function in the "Statistics" palette in ANALYSIS is called "Descriptive Statistics"
Once you drag the channel you want to calculate the average of into the "Channels:" field at the top, deselect all the checkboxes except the "Arithmetic mean" and hit the "OK" button. This will create a new property in that channel called "ResultStatArithMean" at the very bottom of that channel's property table in the Data Portal.
How are you loading your *.CSV files? Are you already using a DataPlugin? If your data files aren't too big, it might be easier to just have the DataPlugin calculate the average for you. Feel free to post a data file, and I'll take a look at that possibility for you.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
03-28-2011 08:47 AM
Brad, No reference to Bloom County. This company manufactures "shredders" primarily for the recycling industry. They can reduce a car to less than fist size pieces in about 20 seconds. We also have technologies to extract and seperate the non-ferrous materials as well, hence "shredderjohn.
Your answer was spot on! Allow me to ask another, how do I round to a whole number the result of "arithmatic mean"?
03-29-2011 07:25 AM
Hi shredderjohn,
Wow, that's some serious shredding. The simple answer to your question is to use the "Round" function. Now tell me how you want to use that "Arithmetic_mean" property-- as an expression in REPORT/VIEW or as a variable in a VBScript?
Brad Turpin
DIAdem Product Support Engineer
National Instruments
03-29-2011 08:23 AM
I see the round function but being a novice programmer I am not sure of how or where to use it. I am using this right now, @@CMax(), in a text to pull a number produced by the method you gave me before. I have tried to put the round function in there but so far no luck. Here is another one for you. I am using script with some success automating reports. I cannot get the channel info to pull onto a reports page. An example is a 2D chart showing hydraulic pressures over a period of six hours. I can do it manually by selecting "time" and then the channel and drag it over. Those manual steps don't show up in the script. I know I am missing some procedure to have those steps automate in script.
03-29-2011 09:29 AM
I have the script issue solved but still need help with "round".
03-29-2011 09:32 AM - edited 03-29-2011 09:37 AM
shredderjohn,
I have no clue how you can reduce the size of a car so quickly, but it sounds awesome!
To round a data set, you will want to use the calculator
and use the Round operation or you could enter something similar to the following eqation into the top portion of the calculator:
Call FormulaCalc ("Ch('Group2/Result'):= Round ('Group1/Input')").
To find out more about the Round function, open Diadem and navigate to Help » Contents and search for "round"
Note: Double click any of the Operations (such as Round) or Channel Names to insert them into your equation.
03-29-2011 02:17 PM
It works fine in the calculator. This is what I have
Round(CMax(86))
I click calculate and the whole integer appears.
I want this to function in a script. I am averaging a channel and calling that result into a text area in a report by using @@(CMax (86))
It also works fine. Where in the .vbs line should I put the Round function? I have tried inserting it after the last ine of the "analysis" to no effect.
I also tried to insert it before the script calls the report.
The shredder works so well because it is a 6000 HP electric motor turnng a rotor that is about 80" by 109" with 14 hammers weighing 410 lbs each at about 500 RPM. Yup, it is damn violent!!
03-29-2011 02:28 PM
It seems I need to calculate the average THEN assign it to a variable THEN call the variable to the text in the report. Yes??
03-29-2011 03:06 PM
Hi shredderjohn,
No, if you just want to reference the rounded average in a REPORT text box, say, then the easiest way would be to use an @@ expression, like this:
Average = @@Round(Data.GetChannel("[1]/ChannelName").Properties("ResultStatArithMean").Value)@@
The "Arithmetic mean" calculation automatically adds the "ResultStatArithMean" property to the data channel whose vazlues were just averaged. You can reference that new property and piggy-back the Round() function in one @@ expression-- just substitute your actual channel name instead of "ChannelName" above.
Brad Turpin
DIAdem Product Support Engineer
National Instruments