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
 All Forums
 Origin Forum for Programming
 LabTalk Forum
 How can I do this?

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
GT-Force Posted - 02/11/2010 : 11:28:46 AM
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
5   L A T E S T    R E P L I E S    (Newest First)
GT-Force Posted - 02/16/2010 : 11:00:48 AM
Great. Thanks for your time and all the info. I'll try these ASAP.

GT
easwar Posted - 02/16/2010 : 09:10:20 AM
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

GT-Force Posted - 02/15/2010 : 11:14:18 PM
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
easwar Posted - 02/15/2010 : 10:56:48 PM
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.=;

GT-Force Posted - 02/15/2010 : 11:20:47 AM
Wow, 20 reads and no replies. I guess what I asked for is not that trivial after all :(

GT

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000