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
 How can I do this?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

GT-Force

USA
4 Posts

Posted - 02/11/2010 :  11:28:46 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I am trying to do this:

I have an XY scatter graph of a column, and I'd like to manually mark two regions by using the regional data selector. Then, I need a script that will fit a line to the first range, displaying at least the slope, and will give me the max, min and max-min for the second range. I have not used Origin before. I guess doing this should be trivial for someone who knows Origin, but I spent a few hours trying to do this to no avail. I'm only visiting a lab and do not have much more time left.

If you can send me the script to do this, with instructions about how to assign a keyboard shortcut or create a toolbar button for it, I'd really appreciate it.

Thank you.

Origin Ver. and Service Release (Select Help-->About Origin): 8.0951

GT

GT-Force

USA
4 Posts

Posted - 02/15/2010 :  11:20:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Wow, 20 reads and no replies. I guess what I asked for is not that trivial after all :(

GT
Go to Top of Page

easwar

USA
1964 Posts

Posted - 02/15/2010 :  10:56:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi GT,

There is an x-function named get_plot_sel which can be used to get ranges corresponding to the two selections. You may need to update your Origin to 8.0SR6 (free patch) for that to work.

Here is a script segment that does LR on the 1st selection. Was not very clear what you wanted stats on, I am assuming you wanted stats on the y data of the 2nd selection.

Easwar
OriginLab


// Assume graph is active with two ranges selected
// Get selection to string
string sel$;
get_plot_sel str:=sel$;
// Declare range using 1st selected range
range r1 = sel.gettoken(1,"|")$;
// Perform linear fit
fitlr r1;
type Linear fit results from 1st part:;
fitlr.=;
// Declare range of the y data for 2nd selected range
range -w r2 = sel.gettoken(2,"|")$;
// Compute stats
stats r2;
type %(CRLF)Stats results from 2nd part:;
stats.=;

Go to Top of Page

GT-Force

USA
4 Posts

Posted - 02/15/2010 :  11:14:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the script. Yes, the y data of the 2nd selection. But I am not interested in all of the stats, but just the min, max and (max-min) values. Is there a way to do that?

And is there a way to run this script by assigning it to a toolbar button or keyboard shortcut?

Thanks again.

GT
Go to Top of Page

easwar

USA
1964 Posts

Posted - 02/16/2010 :  09:10:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi GT,

Once the statement "stats r2" is executed, the min, max values are accessible via
double dmin = stats.min;
double dmax = stats.max;
double diff = dmax - dmin; //etc
Then you can build a string for the text such as:
string mytext$ ="Min = $(dmin), Max = $(dmax), Diff = $(diff)";

You can then place text in a lablel in the graph, see this topic:
http://wiki.originlab.com/~originla/wiki/index.php?title=Script:Creating_and_Accessing_Graphical_Objects

As to running the script from a button, easiest is to assign the script to the custom button, see this topic:
http://wiki.originlab.com/~originla/wiki/index.php?title=Script:Getting_Started_with_LabTalk

You can also create your own custom toolbar or buttons, see this topic:
http://originlab.com/www/helponline/Origin/en/mergedProjects/QuickHelp/QuickHelp/How_do_I_create_custom_toolbar_buttons_that_run_my_script_macros.html

Also, at the end of your script you may want to add the linke
mark -r;
This will remove the data markers from the graph.

Easwar
OriginLab

Go to Top of Page

GT-Force

USA
4 Posts

Posted - 02/16/2010 :  11:00:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Great. Thanks for your time and all the info. I'll try these ASAP.

GT
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