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
 Is there any useful searching function in my case?

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
hkkim Posted - 01/15/2013 : 03:50:54 AM
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 8.1 SR3
Operating System: Windows XP

I want to get an absolute integral area ratio between two graphs.
Here is my example problem. I couldn't find a suitable function in LabTalk yet(<== in below).
Thank you very much!

hkkim

Data-------------RowNo--LastTimeStep--IntegratedValue
============================================
Experiment--------846----8396.2
Calculation-------3622----3492.8--------10676.5

(LastTimeStep = Min(8396.2, 3492.8) => 3492.8 in Calculation)
(Search the nearest time step value in Experiment using 'TimeStep=3492.8' <== Any useful function in LabTalk?) (Let's there is a below data in Experiment.)

Experiment--------329----3493.9--------9920.9

Integration ratio between two graphs: 10676.5/9920.9=1.076 ==> This will be an answer of my code.
4   L A T E S T    R E P L I E S    (Newest First)
hkkim Posted - 01/21/2013 : 8:06:58 PM
Thank you greg! My problem was solved with your help.
I have learned it is necessary to diverse thinking including bug with this case.

hkkim
greg Posted - 01/21/2013 : 10:37:10 AM
This appears to be a bug in 8.1SR3. The script works fine in 9.0SR1.

Adding this line before the integration appears to fix the problem:

R1.SetSize(R1End);

at the expense of deleting all rows of column B after row 329. So a more complete solution requires some safe keeping and restoration of your data:

Dataset ds = R1; // Keep a copy of the original data
R1.SetSize(R1End); // The fix

< integration code goes here >

R1 = ds; // Restore the data
hkkim Posted - 01/21/2013 : 02:34:14 AM
Hi greg!
Thanks! I made a below test code. The variable R1End in integ1 X-function(<== in code) has a reduced value but the R1Area is calculated to an end time not to a reduced time. Why?
If a constant is entered instead of R1End then the result of integ1 function is OK. I tried 'iy:=' of integ1 with a range variable but the result was same. Origin project file was attached for data.

Assumptions:

- There is one workbook(bk1) with 2 worksheets(sh1,sh2).
- The 1st column has time with ascending order and the 2nd(Col(B)) has any data value such as a water level.
- The ranges of R1 and R2 can be different. Let's R1Time is greater than R2Time here.
- The time scales of R1 and R2 can be different, too.

Thanks again!!

hkkim

---------------------------------------------------------------------------------
//
// Calculation of integrated area ratio of two graphs
// 2013/01/18

//
// Reduce row number after checking time steps
//
int R1Size, R2Size, R1End, R2End, i;
double R1Time, R2Time, MinTime, ReducedTime;
double R1Area, R2Area, GraphRatio;
range R1=[bk1]sh1!Col(B);
range R2=[bk1]sh2!Col(B);
R1Size=R1.GetSize();
R2Size=R2.GetSize();

R1End=R1Size;
R2End=R2Size;

type "R1Size = $(R1Size, .0)";
type "R2Size = $(R2Size, .0)";

R1Time=%([bk1]sh1,1,R1Size);
R2Time=%([bk1]sh2,1,R2Size);
type "R1Time = $(R1Time, .2)";
type "R2Time = $(R2Time, .2)";

MinTime=min(R1Time,R2Time);
type "MinTime = $(MinTime, .2)";

if (R1Time != R2Time) // Exit if two end times are same.
{
if (R1Time > R2Time) // Reduce range R1
{
loop (i,1,R1Size)
{
if(%([bk1]sh1,1,i) > MinTime)
{
R1End=i;
ReducedTime=%([bk1]sh1,1,i);
type "R1 Reduced!";
type "ReducedSize = $(R1End, .0)";
type "ReducedTime = $(ReducedTime, .2)";
break;
};
};
};
else // Reduce range R2
{
loop (i,1,R2Size)
{
if(%([bk1]sh2,1,i) > MinTime)
{
R2End=i;
ReducedTime=%([bk1]sh2,1,i);
type "R2 Reduced!";
type "ReducedSize = $(R2End, .0)";
type "ReducedTime = $(ReducedTime, .2)";
break;
};
};
};
};

//
// Calculate two integrated graph areas ratio
//

integ1 iy:=[bk1]sh1!Col(B)[1:R1End] type:=abs plot:=0 area:=0 oy:=<none>; <== Here !!!
R1Area=integ1.area;
type "R1Area = $(R1Area, .2)";
integ1 iy:=[bk1]sh2!Col(B)[1:R2End] type:=abs plot:=0 area:=0 oy:=<none>;
R2Area=integ1.area;
type "R2Area = $(R2Area, .2)";

GraphRatio=R2Area/R1Area;
type "Ratio = $(GraphRatio, .2)";

http://www.originlab.com/ftp/forum_and_kbase/Images/Integ1.opj
greg Posted - 01/18/2013 : 09:22:32 AM
Is this what you need?

dataset dsFound;
vfind ix:=col(2) value:=3492.8 ox:=dsFound tol:=0;
loop(idx,1,dsFound.GetSize())
{
ty $(dsFound[idx]);
}

This searches column 2 for exact (tol:=0) matches of 3492.8 and adds all row indexes where found to the dataset dsFound.

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