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
 Origin Forum
 left of peak center xaty50
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

zknauss

USA
72 Posts

Posted - 08/29/2022 :  09:58:22 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to get the interpolated value of X at the average of minimum and maximum of Y values on the left side of a curve. For a full curve this would be done xaty50(x_y_curve); however this would calculate using data both on the right and left of peak center. I'd like to get the xaty50 using only those x/y values < the x of peak center which I have defined as Xc. Thank!

ZTK

YimingChen

1653 Posts

Posted - 08/29/2022 :  10:55:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Can you try the code below?

bool bOK = x_y_curve.CopyData(vDataX, vDataY);
double dMin, dMax;
uint nIndexMin, nIndexMax;
vDataY.GetMinMax(dMin, dMax, &nIndexMin, &nIndexMax);   
vector newX, newY;
vDataX.GetSubVector(newX, 0, nIndexMax);
vDataY.GetSubVector(newY, 0, nIndexMax);	
Curve crv1(newX, newY);
double halfx = xaty50(crv1);
Go to Top of Page

zknauss

USA
72 Posts

Posted - 08/29/2022 :  4:57:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Before I can test this I'll need to integrate it ino the fitting function just as a double check my data does't always have a true zero as its looking at a set of variable peaks over a period of time which can have high or near zero (no y=0) peak to peak resolution would it be possible to adjust to the formula so instead of looking for a y=0 it would look for when slope(y)=0?
Also to get the curve going from peak max to baseline would this script just be reversed i.e. vDataX.GetSubVector(newX, nIndexMax, 0); Thanks!

ZTK
Go to Top of Page

YimingChen

1653 Posts

Posted - 08/30/2022 :  2:18:55 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The code I provided is just an example that assumes only one peak in the curve and finds the x value at half Ymax to the left of the peak.

Please check the GetSubVector() function page. It returns a subvector by specifying the start and end indices into the vector.
https://www.originlab.com/doc/OriginC/ref/vectorbase-GetSubVector
so to get the curve from peak max to baseline, the code would be
vDataX.GetSubVector(newX, nIndexMax, -1);

James


Go to Top of Page

YimingChen

1653 Posts

Posted - 08/30/2022 :  2:22:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
To check the slope, you will need to take the derivative of the curve. Please check this function.
https://www.originlab.com/doc/OriginC/ref/Curve-Derivative-GlobalFunction

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