Author |
Topic  |
|
jeanbap
alnarp, Sweden
20 Posts |
|
Jose
Netherlands
93 Posts |
Posted - 07/19/2000 : 1:53:00 PM
|
Try the following script (I suppose you have created a fourth worksheet named "rhavg" where you have the results)rhavg_avg=rh1_val; rhavg_avg+=rh2_val; rhavg_avg+=rh3_val; // these three first lines make the sum rhavg_avg/=3; // this last one divides by 3, so makes the average You could do this for more worksheets by using loops: numwks=3; // number of worksheets you want to average (they are all named RH#) rhavg_avg=rh1_val; loop (nn,2,numwks) {rhavg_avg+=rh$(nn)_val;} rhavg_avg/=numwks; I hope this helps. jose. |
 |
|
rtoomey
USA
184 Posts |
Posted - 07/19/2000 : 2:26:00 PM
|
Here's another option: Create a worksheet called AveRh (not RhAve) and add (or rename) two columns in it so that one is called Averages and the other is called Final. Then, execute the following script:
count=0; doc -cws rh; loop(ii,1,count) { sum(rh$(ii)_val); AveRh_Averages[ii]=sum.mean; }; sum(AveRh_Averages); AveRh_Final[1]=sum.mean;
To explain: The first line initializes a variable called count to 0. The second line in this script then determines the number of worksheets in your project which begin with the letters rh and places that number into count. Lines 3 through 7 in the script then loop from 1 to the value in count, perform the sum function on each successive column called rh#_val (where # is a number), and then place that result into a new column (called Averages) in the worksheet called AveRh. Note: The averages worksheet can not be called RhAve in this case since it would be included in the count variable. The last two lines of script then take the average of the averages and report the final average to another column in AveRh (called Final). [This message has been edited by rtoomey (edited 07-19-2000).] [This message has been edited by rtoomey (edited 07-19-2000).] |
 |
|
Jose
Netherlands
93 Posts |
Posted - 07/19/2000 : 2:42:00 PM
|
Dear rtoomey, where you wrote "averh_b" in your script, you should have written "averh_averages", if I correctly understood it. In any case, your script gives, once corrected, the average for every dataset in the first column of "Averh", and then the average of all datasets, as one single number in the second column. My and Jean Baptiste's scripts calculate the average through all datasets *row by row*, that is a different purpose. In any case, by combining yours and mine, I think he would be able to construct the propper one  jose. |
 |
|
rtoomey
USA
184 Posts |
|
Hideo Fujii
USA
1582 Posts |
|
Jose
Netherlands
93 Posts |
|
jeanbap
alnarp, Sweden
20 Posts |
|
jeanbap
alnarp, Sweden
20 Posts |
Posted - 07/21/2000 : 8:09:00 PM
|
Hej igen ! I tried Jose's method. It worked well and so fast !!! I was impressed. The method by rootmey may be faster but it does not give me what I want. Thanks to all of you. BTW, is it possible to use Labtalk to extract worksheet data in a fast way? J-B
|
 |
|
|
Topic  |
|