04-10-2017 02:38 AM
Hello, I really need your help, I must indeed create a macro script that allows to have the average of a number of pièces that we define. thank you
Solved! Go to Solution.
04-10-2017 03:45 AM - edited 04-10-2017 03:46 AM
Here you go:
'Mean of first channels values call MsgBox(cch("[1]/[1]",0)) 'Create array with numbers and calculate mean dim arr : arr = Array(1,2,3,4,5) call MsgBox(mean(arr)) 'calculate mean of array values function mean(arr) dim number, res for each number in arr res = res + number next mean = res / (UBound(arr)+1) end function
If you need anything else, it would be helpful to have more detailed information about your task, e.g. what do you mean by "pièces"?
Regards
04-10-2017 04:42 AM
Hello, I thank you for your answer, indeed, I analyze the crash data of mechanical parts on diadem and I visualize for each mechanical piece the energy curves according to the sink then I make the average of these curves. So I need a script that allows me to have the average of any number of curve I want.
04-10-2017 04:53 AM
For exemple i have this script which calculate the average of 3 functions , so i want to adapt it so i have the ability to enter the number i want of functions. thank you for your help
04-10-2017 04:57 AM
You could also use the descriptive statistics function from analysis module, which calculates a new "mean channel" from any number of input channels if you choose "row-oriented evaluation". Using the DIAdem example_data.tdm file you could do something like this:
Every value of the mean channel is calculated with values of the three other channels, point by point.
If you need the script call for this, just press Ctrl+Shift+C while the analysis dialog for descriptive statistics is open and configured for your requirements. Press Ctrl+V in a script to insert the required code.
Regards
04-10-2017 05:04 AM
Thank you so much i will try it
Regards
04-12-2017 02:31 AM
Hello ,
whene i try your method, i have the result in the picture attached .
Howeever, i don't have a curve of the average of the three resultants , how can i have it and change the colors of the curves ?
Regards
04-12-2017 07:17 AM
My picture from above is a screenshot of a 2D axis system in a report sheet.
After clicking OK or Calculate in the analysis dialog you will find the result channels in the data portal.
If you create an axis system in report or view module you can also set different colors.
In the analysis dialog you will only have a preview of the selected original channels.
04-12-2017 03:12 PM
Hi say,
The configuration you show in your image looks fine. There are two tabs to that dialog, though, and the punch line is on the "Result Storage" tab. If in that tab you have "Store results in channels" checked and then you click on the "Calculate" or "OK" button at the bottom, you'll get the channels you want.
Brad Turpin
DIAdem Product Support Engineer
National Instruments
04-13-2017 02:54 AM
Hello,
Thank you so much !
Regards