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
 LabTalk Forum
 Finding def. value in row and extr. column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

cement

Germany
2 Posts

Posted - 06/17/2016 :  11:55:40 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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



cement

Germany
2 Posts

Posted - 06/24/2016 :  5:33:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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
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