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
 PointProc and Doc -e DY
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

CStorey

Canada
137 Posts

Posted - 10/17/2001 :  12:26:05 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
--> I've also sent this to tech support. But since it's a similar problem to perger's I thought I would post it here too.

Hello,

This is the first time I've tried to program the DoToolBox. I'm trying to write a script for Origin 6.1 that will allow the user to select the range over which to do a LR/fit to each curve in the graph. I've tried to do this with doc -e DY and dotool -dh 4. The problem is that the doc -e DY command does not wait for the execution of PointProc or EndToolBox. This cause problems with indices I'm using to record the results as well. I can insert a delay using sec -p X but this isn't acceptable as it doesn't always allow the markers to be moved (why?). Is there a way to do this properly??

Here's what I have tried ...

[RangeSelect]
type.redirection=1; // All "type" statements are printed to the 'Script Window'
system.debug=1; // Debugging is turned ON!

////// Create a Worksheet for the Output //////
win -t wks Origin WksXInt; // Create a new worksheet
%N=%H; // Remember worksheet name
wks.col1.format=2; // Set Colum A as Text
wks.col1.name$="Curve"; // Rename A to Dataset
wks.col2.name$="Xint";
wks.col1.width=20; // Widen to 2 chars

nmo=1; // Initialize Counter
win -a Graph1; win -z; // Makes "Graph1" active graph and Maximized!

#!type "Begining Linear Regression for X-intercept";

///// Loop over all the Datasets in all layers of Graph1 /////
doc -e DY {

type "Analysisc for %V";
dotool -dh 4; // Open the Data selector tool -dh -r -s

////// Macro that defines what to do after points are selected //////
def PointProc
{
%B=getpts.xData$;
%B[getpts.count]=x;
%B=getpts.indexData$;
%B[getpts.count]=index;
if (getpts.count>=getpts.max)
{
%V=%C; // Capture the Current Dataset name
{EndToolbox %V nmo}; // If points were selected then Run the EndToolBox Macro
doTool 0;
}
else
doTool -next;
};

////// Macro that defines LR analysis /////
def EndToolBox
{
// The index of the selections are stored in variables mks1, mks2
type "%2 Dataset: %1";
// Do LR over selected range!
lr -n %1 -b mks1 -e mks2; // Do LR over the range selected -b == BEGIN, -e==END and -n DO NOT draw a line
xintercept=-1*(lr.a)/(lr.b); // Calculate the x-intercept from y=mx+b --> y=(lr.b)x + lr.a , thus x(y=0)=-1*(lr.a)/(lr.b);
type " --> Slope = $(lr.b,%9.4g) +- $(lr.sdB,%9.4g)"; // %9.4g is C style formatting
type " --> Y-intercept = $(lr.a,%9.4g) +- $(lr.sda,%9.4g)";
type " --> Correlation R = $(lr.r,%9.4g)";
type " --> X-intercept = $(xintercept,%9.4g)";
%N_Curve[%2]$="%1"; // Record Dataset name
%N_Xint[%2]=xintercept; // Add x-intercept to worksheet
type " "; // Insert a blank line
};

nmo=nmo+1; // Increment counter

};

Return;

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring

Edited by - CStorey on 10/17/2001 12:59:25

CStorey

Canada
137 Posts

Posted - 10/17/2001 :  2:11:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
One more interesting problem.
If I use Doc -e inside the EndToolBox (which is not really what I want to do) then I get one extra curve in the loop that is not plotted in the graph. This extra curve is called "MARKER" it's easy to skip but maybe doc -e should not loop over this to begin with?

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring
Go to Top of Page

Laurie

USA
404 Posts

Posted - 10/17/2001 :  5:50:30 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Craig,

I also had some trouble using doc -e DY. What about using something like the following? It seems to work pretty well.

[main]

layer -c;
loop(ii,1,count)
{
%C=%[%Z,#ii];
run.section(,LRAnalysis);
}


[LRAnalysis]

type -b "Select the range of data for the fit.";

dotool 4;
def pointproc{
lr -n %C -b mks1 -e mks2;
type -a "Slope value is $(lr.b).";
type -a "Intercept value is $(lr.a).";
done=1;
dotool 0;
};
for(done=0;done==0; ) {
sec -p .05;
}



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