DIAdem

cancel
Showing results for 
Search instead for 
Did you mean: 

Script

Solved!
Go to solution

Hello,

i'm triyng to write a script that call tha channels which are in the internal data in order  to calculate the mean of them. what can i write please ? 

0 Kudos
Message 1 of 13
(3,694 Views)

Hi say,

Where's the difference to your questions here?

http://forums.ni.com/t5/DIAdem/Macro-script/td-p/3610527

http://forums.ni.com/t5/DIAdem/Mean/td-p/3613342

http://forums.ni.com/t5/DIAdem/script-Mean/td-p/3614017

It does not help to open multiple threads for the same question and it will not be faster.

 

You will also find lots of documentation and examples in the internet and installed with DIAdem to do a calculation of mean values.

Here are some examples:

http://zone.ni.com/reference/en-XX/help/370858M-01/dlgmaths/calc_statistics_dlg/dlgstatblockcalc_dia...

http://zone.ni.com/reference/de-XX/help/370858M-0113/comoff/chnaverage/

http://forums.ni.com/t5/DIAdem/How-do-you-do-an-average-of-only-ONE-channel-in-analysis/td-p/1498638

 

If this does not help, please provide detailed information first, so we can help you to solve the problem.

 

Regards

Christian
CLA, CTA, CLED
0 Kudos
Message 2 of 13
(3,669 Views)

Hello christian,

Thank you for your message .To better explain what i mean , attached the script that i wrote to have the mean of three test, i want. i want to have the same script but that allows to have this mean whatever the number of test i have. i thought to run it in a loop but i did not know how to write it !

Regards 

0 Kudos
Message 3 of 13
(3,635 Views)

You can do it like this and you will not need a loop at all:

dim ForceChnList
set ForceChnList = Data.GetChannels("*/force")
call Data.Root.ChannelGroups.Add("Results").Activate()
call ChnAverage(ForceChnList, "/Mean")

The GetChannels command searches for all channels with name "force" in all groups and will return an ElementList that can be used with ChnAverage command.

http://zone.ni.com/reference/en-XX/help/370858M-01/inavidata/objects/diacmpnt_objects_idiademelement...

Christian
CLA, CTA, CLED
0 Kudos
Message 4 of 13
(3,612 Views)

hello christian,

Thank you so much for your answer, i understand that this syntax allows to call all the elements named 'force' and calculate the mean , i wrote this syntax for the three element that i treat( attached). However, it does not display curves on the report , any ideas ? 

Regards

0 Kudos
Message 5 of 13
(3,596 Views)

Your script creates a new group for every result channel.

If you try to create a group that already exists, DIAdem will create a new group with an index at the end.

Only create and activate the group once at the beginning.

I don't know if this solves your report problem as well.

You have to provide more information to describe your problem.

Christian
CLA, CTA, CLED
0 Kudos
Message 6 of 13
(3,588 Views)

hello christian

Thank you for your help , well, i'm doing currently some test, which give me data(energy, force...) that i pos treats by diadem, i must for each number of test calculate the mean, i wrote a script for three and five test ( as you can see in the pictures attachd) , and now i have to write a script that allow me to calculate this mean whatever the number of test i do. i'm really desperate , any help please ? 😞

Download All
0 Kudos
Message 7 of 13
(3,569 Views)
Solution
Accepted by topic author say12

Hi say,

 

Christian gave you the important tip to use the Channel List approach-- this enables you to have the same code respond to any number of input channels, so long as their channel names are the same.  You just need to loop that code over your 3 channel names, like this:

dim ChanList, ChnNames, ChnName, ResultGroup, ResultChannel
ChnNames = Array("force", "force_xyz", "Energy")
set ResultGroup = Data.Root.ChannelGroups.Add("Results")
Call ResultGroup.Activate()
FOR Each ChnName In ChnNames
  set ResultChannel = ResultGroup.Channels.Add("Mean_" & ChnName, DataTypeChnFloat64)
  set ChanList = Data.GetChannels(ChnName)
  call ChnAverage(ChanList, ResultChannel)
NEXT ' ChnName

 

Brad Turpin

DIAdem Product Support Engineer

National Instruments

0 Kudos
Message 8 of 13
(3,564 Views)

thank you so much for your help , i'm going to think about all thoses solutions!

Regards

0 Kudos
Message 9 of 13
(3,556 Views)

Oops, i have an error in the line 23 , Error : No channel or only one channel selected==> cannot calculate mean , any ideas ? :'( :'( :'( 

0 Kudos
Message 10 of 13
(3,545 Views)