T O P I C R E V I E W |
thomsen01 |
Posted - 04/28/2014 : 09:52:30 AM OriginPro 9.1.0G (32-bit) SR2, Win7
Hello!
How can I get the row number of a median? For example I have a datasheet with 1 column: 2 3 1 6 7 8 3 with the function: db=median(col(1)[1:5],2); db=; I can get the median of the first 5 rows and it's "3", but how can I also get the row number (in this case "2")? Thanks for your help!
Thomsen |
3 L A T E S T R E P L I E S (Newest First) |
thomsen01 |
Posted - 04/30/2014 : 09:26:49 AM Thank you for the answers.
Unfortunately I have no possibility to sort my dataset, but the second solution by greg works fine with a few adjustments.
Thanks for your help.
Thomsen |
greg |
Posted - 04/28/2014 : 3:53:39 PM Without sorting, if you know the median is unique, you can use this:
range raD = [Book1]Sheet1!col(2); MedianRow = list(median(raD,1),rad);
But it's possible the median exists more than once, in which case you can use:
dataset dsIdx; range raD = [Data1]Sheet1!2; MedianValue = median(rad,1); vfind value:=MedianValue ix:=rad ox:=dsIdx; loop(ii,1,dsIdx.GetSize()) { ty $(MedianValue) in row $(dsIdx[ii]); }
Note that only option 1 of the Median function returns a value that is actually found in the data. |
lkb0221 |
Posted - 04/28/2014 : 11:40:40 AM Hi,
If you can sort the dataset first, function index can be used. http://www.originlab.com/doc/LabTalk/ref/Index-func
But if your data have to be non-monotonic, you may use list function to find the index when it first appears. http://www.originlab.com/doc/LabTalk/ref/List-func
Zheng OriginLab |
|
|