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
 Forum for Origin C
 Q: getting row index of specified dataset 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
hajo_old Posted - 02/21/2003 : 09:42:48 AM
Hello, all

does anyone know how I can get the rowindex of a specified dataset value.

Example:

dataset ds (size:200 elements)
now I'm looking for the maximum of the values within the dataset and get the row-index back.

analog to the function XfromYmax but as function
X from specified Y value

hope you get what I mean ....

Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1
5   L A T E S T    R E P L I E S    (Newest First)
hajo_old Posted - 02/24/2003 : 1:55:46 PM
Hello, Easwar

thanks for your suggestion.
This works reliably now!

Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1
easwar Posted - 02/24/2003 : 09:43:21 AM
Hajo,

Try the following function code, where -1 is used as the precision argument - see comment in code.

Easwar
OriginLab.

int findmaxindex(string strDataset)
{
Dataset dsY(strDataset);
if(dsY)
{
double dMax = max(dsY);
int iRow = Data_list(dMax, &dsY, -1);
//Pass -1 to use Origin's default internal double comparison precision
//as specified by the @ND system variable
if(iRow == -1)
printf("Error!\n");
else
printf("Max value of %f found at index %d\n", dMax, iRow+1);
return iRow;
}
}


hajo_old Posted - 02/23/2003 : 3:33:23 PM
Hello, all

thanks for your replys.
I allready foud out about the Data_list() function and thought there is a function like the LabTalk list()-function as Mike pointed out. As I can get the maximum of the dataset by the max() function I know the exact value!
But I don't know the exact index, the max function found the value.

So, I would look for a function like:
[maximum, index] = max(dataset);

I tried to use the Data_list() function with several precision values and didn't get the sense in my case (I know the exact value.) because with different values for the precision parameter I got different indices for the matching dataset value!

So, the question is, what precesion is the right when knowing the exact value I'm looking for within the dataset by using the Data_list() function?

Thanks
Hajo

-- --
Dipl.-Ing. Hans-Joerg Koch
Siemens VDO, Regensburg

SVDO_Origin1
Mike Buess Posted - 02/21/2003 : 10:42:58 AM
quote:
The Data_list function also has a third argument to set the precision for matching the value.


That's a big improvement over the LabTalk list() function, which requires an exact match.

Mike Buess
Origin WebRing Member
easwar Posted - 02/21/2003 : 09:59:14 AM
Hi Hajo,

You can use the Data_list function, as in the example code below. The Data_list function also has a third argument to set the precision for matching the value.

Easwar
OriginLab.


void findy(string strDataset, double y)
{
Dataset dsY(strDataset);
if(dsY)
{
int iRow = Data_list(y, &dsY);
if(iRow == -1)
printf("value not found!\n");
else
printf("found %f at row index %d\n", dsY[iRow], iRow+1);
// iRow+1 for row index in GUI, iRow for row index in OC
}
else printf("invalid dataset!\n");
}



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