The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Row number of a median value

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000