In Origin 2018 and 2018b, we support cell formula in User-Defined Parameter rows and Data area of worksheet. You can easily type =Mean(C) to calculate mean of column C or =Mean(This) to calculate mean of current Column.
In Versions before Origin 2018, you can calculate each column’s mean and size in worksheet and put them in column label rows by a few lines of LabTalk Script.
wks.userparam1$ = Mean; //define a user-defined parameter row
wks.userparam1 = 1; //show this row named "Mean"
wks.userparam2$ = Size;//do the same for a "Size" row
wks.userparam2 = 1;
//calculate Mean and show 3 significant digits
wcol(j)[Mean]$ = $(mean(wcol(j)),*3);
//show 0 decimal places for Size
wcol(j)[Size]$ = $(count(wcol(j),1),.0);
As you can see from the code above, you can use the user-defined parameter row’s name as cell row index to access it directly.
If you want to show it immediately after import and dynamically update with change of data, and save the script with the worksheet for future uses, here are the steps:
- Choose Worksheet: Worksheet Script… menu.
- Copy the Script above into the big box in the dialog.
- Check After Script and Upon Changes in Ranges(s) (space separated) checkboxes.
- Enter 1:end as the range so changes in any column will trigger the script.
- Click Do It or Update button.
- Choose File: Save Template As… and give a meaningful template name, e.g. Mean_Size_in_Label.
- Choose File: Recent Book: or use Open Template button to load it and enter some data to see the update in Mean and Size rows.