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
 Get/Set DataRange-Rows by axis 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
hofmaale Posted - 01/14/2014 : 10:51:25 AM
Hi there.

I thought this youd be an "easy to solve" problem - however up to now (that is, 4 Hours of searching) - I failed.

The goal is to automate integration of multiple datasets with the same parameters, that is, the same start- and end-values in X-Axis-Coordinates.

I managed to write an OriginC-Script to integrate all curves in the active graph and write the results to a new worksheet.

The Script uses GetDataMarkers to get the Start & End Row-Index of the currently selected curve, so that the user can visually select the data to integrate.

But, as there is no easy relationship between row-index and the x-column-value at this index, the integration is only valid for the currently selected curve (measurement data starts at different time-values (X), but hast to be integrated e.g. from 0µs to 40µs).

So, what I'm trying to do is: get X-Axis-Values for the position range selected, and calculate the rows to select for each curve being integrated.

I could retrieve all data from the selected curve's X-Column, look up the value at the given index and then calculate the new index by retrieving all Data for all the other curves - but I think there must be some functionality like this already present in Origin?

When manually integrating the data, the range used looks something like this: [Book]Worksheet!("A":"B")[x0.7:40.7], with the two extends of the integration 0.7 and 40.7 in X-Axis coordinates.

However, I'm not able to reproduce this when creating range-objects by instantiating DataRange, DataRangeEx or XYRange. The Reference tells me that DataRangeEx can be used to initialize a range by using a similar syntax, but it does not seem to work as I thought it would (see http://ocwiki.originlab.com/index.php?title=Category:DataRangeEx_%28class%29)

Do you know any possibility to initialize Range-Objects by Coordinate-Values (not row-indices)?

Thanks in Advance

Alexander



---------------
Origin Ver. and Service Release: 9.1.0G Sr1
Operating System: Win XP
3   L A T E S T    R E P L I E S    (Newest First)
hofmaale Posted - 01/15/2014 : 09:31:27 AM
After another hour I succeeded in doing what I wanted.

ocmath_numeric_integral really is easier to use compared to the XFunctions called from C++; however I could not find any way to automatically generate Ranges from Axis-Coordinates (the functions ends it's integration at a given x-Value in axis coordinates, but it starts at position 0 in the input vector, which might not be 0 in coordinates).

This, hovever, was not as complicated as I thought it would be:

int findNearestX(Dataset &dX, double value)
{
	int startIndex = dX.GetLowerBound();
	double dif = abs(value - dX[startIndex]);
	double newDif = dif;
	for (int ii=startIndex+1; ii <= dX.GetUpperBound(); ii++)
	{
		newDif = abs(value - dX[ii]);
		if (newDif > dif)
		{
			return ii-1;
		}
		dif = newDif;
	}
	return dX.GetUpperBound();
}


See the complete script here:
http://pastebin.com/yYGbUiUa

Thanks again for the hint!
hofmaale Posted - 01/15/2014 : 05:11:41 AM
Hi,

thanks for your reply.

ocmath_numeric_integral would replace my call to the integ1-XFunction, but still I would have to slice down the data to the relevant portion by hand (the measurement covers some 500µs, containing all rubbish except 40µs of relevant data somewhere in the middle).

Although, as for the way you suggested I'll need the data in a vector anyway, this would probably produce no significant overheat and is probably easier to implement as calling the XFunction.

I'll check that!
Castiel Posted - 01/14/2014 : 11:11:28 AM
I think you got things too complicated...just get data from a DataRange and perform the integration:
BOOL DataRange::GetData( vectorbase * pData, int nIndex )
and
int ocmath_numeric_integral( double x, double * py, uint npts, const double * pxData, const double * pyData )

You may want to take a close look at the latter one.



©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦

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