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
 Forum for Origin C
 baseline subtraction
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

belmore

USA
Posts

Posted - 06/11/2007 :  1:20:57 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version 7.5Pro
Operating System: Win Vista

Hello: I work with visible light absorption spectra consisting of wavelength (x) and absorption values (y). Frequently, I need to do baseline correction by selecting a y-value where the species of interest does not absorb light and then subtracting this from the y-column. What I want to do is input a wavelength (value in the x-column) and then have y-value in that row subtract from the entire column.

My problem is, I do not any experience with Origin C or any flavor of C. I think I need something more basic than the information given in the tutorial.

Any suggestions/references for a complete newbie?







Edited by - belmore on 06/11/2007 1:43:18 PM

Mike Buess

USA
3037 Posts

Posted - 06/11/2007 :  2:26:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Add the following function to CodeBuilder's workspace as explained here and run it by entering subtractYatX(wavelength) in the script window. Function assumes X and Y are in cols 1 and 2, respectively.

void subtractYatX(double dXval)
{
Worksheet wks = Project.ActiveLayer();
Curve cc(wks, 0, 1);
double dYval = Curve_yfromX(&cc,dXval);
cc -= dYval;
}

Mike Buess
Origin WebRing Member
Go to Top of Page

belmore

USA
Posts

Posted - 09/14/2009 :  1:39:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
More help required.

This solution works fine if I have only one Y-column of data. But I have one X-dolumn (wavelength) and many Y-columns (Absorbance values).

I want all the columns in worksheet to subtract the value of that individual column's value at a single wavelength

Thanks
Go to Top of Page

easwar

USA
1964 Posts

Posted - 09/14/2009 :  2:35:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

You can do this as a simple loop operation from the script window. Use Window:SCript window menu item to open the script window. Then with your XYYY... worksheet active, paste these lines and select them all and press Enter:

for(int ii=2; ii<=wks.ncols; ii++)
{
wcol(ii) -= wcol(ii)(848);
}

Note: Replace the number 848 above with whatever is the wavelength number you need. The wcol(ii)(848) notation will find the Y value at that number, and if the exact number does not exist in your X column, it will interpolate to find the y value at that x and then subtract that interpolated value.

If you need more help please contact tech support.

Easwar
OriginLab
Go to Top of Page

belmore

USA
Posts

Posted - 09/14/2009 :  3:19:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry, Easwar:

I can't get that simple script to work.brad
Go to Top of Page

easwar

USA
1964 Posts

Posted - 09/14/2009 :  8:58:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Brad,

The "int ii" inside the for loop is only supported starting in Origin 8. My apologies, you have Origin version 7.5 so try this script instead, where the "int" is dropped:

for(ii=2; ii<=wks.ncols; ii++)
{
wcol(ii) -= wcol(ii)(848);
}

If that does not work, please send an e-mail to us with your project/data.


Easwar
OriginLab

Go to Top of Page

belmore

USA
Posts

Posted - 09/16/2009 :  1:02:12 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Works like a charm!

Thank you.

I apologize for not updating my software.

Regards,
Brad
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