DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Macro script

Solved!
Go to solution

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 

0 Kudos
Message 1 of 10
(3,568 Views)

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

Christian
CLA, CTA, CLED
0 Kudos
Message 2 of 10
(3,540 Views)
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. 

 

0 Kudos
Message 3 of 10
(3,531 Views)

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 

0 Kudos
Message 4 of 10
(3,526 Views)
Solution
Accepted by topic author say12

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:

Mean.PNG

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

Christian
CLA, CTA, CLED
0 Kudos
Message 5 of 10
(3,524 Views)

Thank you so much i will try it 

Regards

0 Kudos
Message 6 of 10
(3,519 Views)

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 

0 Kudos
Message 7 of 10
(3,469 Views)
Solution
Accepted by topic author say12

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.

Christian
CLA, CTA, CLED
0 Kudos
Message 8 of 10
(3,460 Views)
Solution
Accepted by topic author say12

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

0 Kudos
Message 9 of 10
(3,437 Views)

Hello,

Thank you so much !

Regards

0 Kudos
Message 10 of 10
(3,422 Views)