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
 peak finding/peak height
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gatordan82

USA
7 Posts

Posted - 11/23/2010 :  6:34:47 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8.0.63.988 SR6
Operating System: Windows XP

I have a bit of code that's supposed to find the peak values of a dataset at three different intervals in x. After a background removal I loop through each spectrum to find these peaks. The problem is that for one of the peaks, it is usually very small amplitude, and sometimes so small that it's in the noise level. I would like to get my code to find the peak value if it can (positive peak, not a trough) and output the amplitude, or if it can't find the peak, output the maximum y value over the specified x-range.

I've tried using the max function and limit function with not much success. A main problem is that if the pkfind function doesn't find a peak, it ends the script. Is there a way to do some kind of if/then structure for it the pkfind search fails go to finding the max value?

Here's the pertinent snippet from my code:

loop(jj, 2, n)
{
pkfind iy:=wcol(jj)[200:400] method:=first filter:=num value:=1 ocenter_x:=wcol(n+1) ocenter_y:=wcol(n+2);
pkfind iy:=wcol(jj)[950:1150] method:=first filter:=num value:=1 ocenter_x:=wcol(n+3) ocenter_y:=wcol(n+4);
pkfind iy:=wcol(jj)[80:140] dir:=p method:=first filter:=num value:=1 ocenter_x:=wcol(n+5) ocenter_y:=wcol(n+6); //This is the problem peak
ratio[jj] = wcol(n+4)[1]/wcol(n+2)[1];
dratio[jj] = wcol(n+6)[1];
wks.ncols = n;
}

Sam Fang

293 Posts

Posted - 11/23/2010 :  10:48:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You can use a brace "{}" to enclose the script. Then if it doesn't find a peak, it will continue and not end the script.
---------------------------------------
{pkfind iy:=wcol(jj)[80:140] dir:=p method:=first filter:=num value:=1 ocenter_x:=wcol(n+5) ocenter_y:=wcol(n+6);} //This is the problem peak

---------------------------------------

Sam
OriginLab Technical Services

Edited by - Sam Fang on 11/23/2010 10:49:56 PM
Go to Top of Page

Laurie

USA
404 Posts

Posted - 12/06/2010 :  5:35:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Also, please check out the following link:

http://www.originlab.com/www/helponline/Origin/en/programming/mergedProjects/LabTalk/LabTalk/X-Function_Exception_Handling.html

OriginLab Technical Support
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