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
 Extracting y values from graph
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Curie

Germany
2 Posts

Posted - 01/20/2010 :  09:39:20 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): V8 SR1
Operating System: XP (SP3)

Hi,
I want to extract the y data values from a "line graph" using e.g. the screen reader tool. I know this task should be easily achievable usign the GETPTS command but unfortunately I am not familiar writing scripts at all. Could somebody please give me a detailed explanantion on how to extract the y values of the graph into a new working sheet by double klicking onto the graph at given points ?
Thanks a lot,
Daniel

easwar

USA
1964 Posts

Posted - 01/20/2010 :  12:22:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Daniel,

There are examples on this LabTalk Scripting Guide wiki page:
http://wiki.originlab.com/~originla/wiki/index.php?title=Script:Getting_Points_from_Graph

Version 8.1 ships with a printed form of the LabTalk Scripting Guide.

I took one of the examples from there and modified to screen reader. so in the code below, the x value at the point clicked is used, and then the y value of the active curve in the graph is found using interpolation with the %c(x) syntax. This syntax does interpolation as needed to find the y, as the x chosen can be an arbitrary value and not a point in the curve.

Easwar
OriginLab


dataset dsx, dsy;  // Create two datasets to hold the X and Y values
dotool 2;          // Start the screen reader tool
// Define the macro that runs for each point selection
def pointproc {
    count++;         // Increment count
    dsx[count] = x;  // Get the X coordinate
    dsy[count] = %c(x);  // Get the Y value of active curve using interpolation
}
 
// Define a macro that runs if user presses Esc key, 
// or clicks the Pointer Tool:
def quittoolbox {
   count=;
   for(int ii=1; ii<=count; ii++)
   {
      type $(ii), $(dsx[ii]), $(dsy[ii]);
   }
}
count = 0;  // Initial point
type "Click to select point, then press Enter";
type "Press Esc or click on Pointer tool to stop";
Go to Top of Page

Curie

Germany
2 Posts

Posted - 01/21/2010 :  09:20:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot Easwar for the very fast response and your help. I was chatting with Origin support yesterday evening and I also got a good solution for my problem.(Thanks Laurie ;) These scripts will make my work a lot easier from now on.
Daniel

For anybody who might also need this:
%W=%H;
newbook result:=strnewbook$;
win -s TV; win -a %W;
range rYOut = [strnewbook$]1!wcol(2);

dotool 2; // Start the tool

// Define the macro that runs for each point selection
def pointproc {
count++; // Increment count
rYOut[count] = y; // Get the Y coordinate
}

count = 0; // Initial point
type "Click to select point, then press Enter";
type "Press Esc or click on Pointer tool to stop";
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