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
 Finding def. value in row and extr. column

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
cement Posted - 06/17/2016 : 11:55:40 AM
OriginPro 205 G Sr2b9.2.272
Win 8.1 (64)

Hi there,
I'm new to this forum and hope my question isn't too stupid:

I have a large table and would like Origin to find the minimum value in a defined row (say row 6) and in a next step pass back the column number, the minimum was found in, in order for me to be able to use the data in this column for further calculations.

I tried
void FindMinCol()
{
Worksheet wks = Project.ActiveLayer();
DataRange dr;
dr.Add("Parameter", wks, 1, 1, 18, 19);
double mi, ma;
mi = min(dr);
}

But allready during this step I get the following error during compiling:
":Fehler, Funktion oder Variable min nicht gefunden" and "Fehler, allgemeiner Kompilierungsfehler"

Any help would be greatly appreciated!
Thanks very much
Michael



1   L A T E S T    R E P L I E S    (Newest First)
cement Posted - 06/24/2016 : 5:33:50 PM
Hi Forum Members,

Origin Help desk came up with the following solution - and it works!

void find_min_max()
{
Worksheet wks = Project.ActiveLayer();
if ( wks )
{
int nR1, nR2, nC1 = 0, nC2 = wks.GetNumCols() - 1;
wks.GetBounds(nR1, nC1, nR2, nC2);
matrix mat;
mat.CopyFromWks(wks, nC1, nC2, nR1, nR2, 0); // Copies a specified range from a worksheet to a matrix.
int nMatRows = mat.GetNumRows();
for ( int ii = 0; ii < nMatRows; ii++ )
{
vector vRow;
mat.GetRow(vRow, ii); //get one row data to do stats

double dMin, dMax;
int nMinIndex, nMaxIndex; //this will correspond to column index in this case
vRow.GetMinMax(dMin, dMax, &nMinIndex, &nMaxIndex);

string strMsg;
strMsg.Format("Row %d: Min = %lf At %d, Max = %lf, At %d\n", ii, dMin, nMinIndex, dMax, nMaxIndex);
printf(strMsg);
}
}
}

Thanks for the help of Origin Support!
Best Michael

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