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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Simple Q: how do you get the index of a cell?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

northpig87

Canada
2 Posts

Posted - 05/01/2009 :  12:55:28 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.0891
Operating System: WinXP

Hello all,

a part of my code can look through a column and find the max value and write it out to a cell fro number of worksheet...now I also want to know the row number where that maximum value was at. How do I do that?

Column col_temp(wksData,2);
Dataset maxfittedy(col_temp);
double maxpeak;
maxpeak=max(maxfittedy);

this is what I did to find the max value of Column #2 of wksData and stored it in a double maxpeak. very simple (i'm totally beginner).

so what can I do to find the position of this max value returned by max(maxfittedy)?

Thank you very much!!!!!

cjfraz

USA
22 Posts

Posted - 05/05/2009 :  11:35:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
There's probably several valid ways to do this, but my suggestion would be to use the GetMinMax method of the vector class as it will easily return indices...

void bb(){
	Dataset dsTemp("Book1",1);
	uint indexMin,indexMax;
	double dMin, dMax;
	dsTemp.GetMinMax(dMin, dMax, &indexMin, &indexMax);
	printf("min: %3.2f\nmax: %3.2f\niMin: %i\niMax: %i", dMin, dMax, indexMin, indexMax);
}



J...
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000