ATTENTIONThis FlexSim Community Forum is read-only. Please post any new questions, ideas, or discussions to our new community (we call it Answers) at https://answers.flexsim.com/. Our new Question & Answer site brings a modern, mobile-friendly interface and more focus on getting answers quickly. There are a few differences between how our new Q&A community works vs. a classic, threaded-conversation-style forum like the one below, so be sure to read our Answers Best Practices. |
flexsim.com |
|
Downloads |
Q&A Using Flexsim and building models |
#1
|
|||
|
|||
Does there exist a function that can calculate the time weighted average of a value in a Global tabl
I have a value in a Global table. The value changes through time.
I want to calculate the time weighted average of the value as a PFM in the experimenter tool. But I cannot find a function to do this. Does there exist a function that can calculate the time weighted average of a value in a Global table? Last edited by Cliff King; 01-20-2008 at 11:14 PM. |
#2
|
||||
|
||||
There are no functions that calculate a time weighted average, but the formula is pretty easy: A = (V1*T1 + V2*T2 + ...) / TotalTime
You could also use the Recorder object which will dynamically calculate a running weighted average by time or by occurence. Choose these options on the Recorder: Type of Data: User-defined Data Output type: Min/Max/Average Weight averages by time |
#3
|
|||
|
|||
Thanks,Cliff.
Yes, now I am using recorder to get the value. Then I want to get the value of recorder in the experimenter PFM trigger. I use the getnodenum() function to get the value of the recorder. But it doesn't work. Below is what I use. getnodenum(node("/Recorder1>variables>graphdata>MAIN:/project/model/Tools/GlobalTables/Table1/variables/data/total/1/AvgValue", model())); The function doesn't return correct. Why? How to reslove it? Please help. |
#4
|
||||
|
||||
Unfortunately the name of the row node in the graphdata table variable of a Recorder object happens to be the path to the node(s) it is recording, which in your case is MAIN:/project/model/Tools/GlobalTables/Table1/variables/data/total/1. This confuses Flexsim when it tries to follow the path in your getnodenum(node()) expression as you can imagine. You also made the mistake of using > when you needed to use /. Remember that > is used to "dive" into the object data of a node, and / is used to simply drop down one level in hierarchy.
I suggest you refer to the row node in the graphdata table by rank instead of name. In a string defining the path to a node, if the first character following a special character is a number then it is interpreted as the rank of the next node rather than the name. So in other words, if your recorded variable is in the sixth row of the graphdata table, you could use this expression: getnodenum(node("/Recorder1>variables/graphdata/6/AvgValue", model())); As a tip, one sure way to get the full path to a node in the tree using all ranks is to right-click on the node in the tree and choose Edit | Designate This Node so(), then from a Script window type nodetopath(so(),0); and hit Execute. You can then copy the string from the window and paste it directly into node(" ") This will always work so long as you do not change the ranks of any nodes refered to in the path. Those nodes which might change rank in the model, you will need to replace the rank number with the name of the node/object. This will |
Thread | Thread Starter | Forum | Replies | Last Post |
Displaying the simulation time with the various date/time formats. | Regan Blackett | Tips and Tricks | 12 | 11-12-2012 08:01 AM |
Excel and global tables | Bill Nordgren | Q&A | 2 | 10-15-2007 04:36 AM |