04-18-2017 04:11 AM
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 ?
Solved! Go to Solution.
04-18-2017 06:16 AM
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/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
04-19-2017 01:35 AM
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
04-19-2017 04:24 AM
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.
04-19-2017 06:46 AM
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
04-19-2017 06:54 AM
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.
04-19-2017 08:11 AM
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 ? 😞
04-19-2017 08:25 AM
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
04-19-2017 08:28 AM
thank you so much for your help , i'm going to think about all thoses solutions!
Regards
04-19-2017 08:48 AM
Oops, i have an error in the line 23 , Error : No channel or only one channel selected==> cannot calculate mean , any ideas ? :'( :'( :'(