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 to remove data points
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Mats77sv

Sweden
10 Posts

Posted - 08/29/2014 :  5:04:37 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.1
Operating System:win7

Hi,

I am looking for a way to remove data points but only if certain requirements are satisfied. If data points in col(3) take the value of col(3)>=col(2)*0.9 then data points should be deleted if the next 4 data points have similar values. I have tried with:

csetvalue col:=col(3) formular:=col(3) >= col(2)*0.9 ? 1/0 : col(3) recalculate:=0;
csetvalue col:=col(3) formular:=col(2)==NANUM?--:col(3) recalculate:=0;

But how do I make it work only on data points where col(3)>=col(2)*0.9 in 4 rows right after each other? Is it even possible in Origin?

Kathy_Wang

China
159 Posts

Posted - 09/01/2014 :  05:24:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

An approach I could think of is to add a 4th column as reference and define it as col(3) >= col(2)*0.9 ? 1 : 0 so it fills with 1 or 0, and then you can sum up the reference values for the next 4 data points and if the value is 4, then this data point should be removed, and otherwise, it should be kept.

An example would be:


csetvalue col:=col(4) formula:="col(3) >= col(2)*0.9 ? 1 : 0" recalculate:=0;
csetvalue col:=col(3) formula:="col(4)[i+1]+col(4)[i+2]+col(4)[i+3]+col(4)[i+4]==4?1/0:col(3)" recalculate:=0;


And you may need to change the condition a bit according to your specific need (i.e does the 4 points include the data point itself.etc)



Kathy
Originlab
Go to Top of Page

Mats77sv

Sweden
10 Posts

Posted - 09/02/2014 :  4:23:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Kathy,

Thank you for your quick reply.

Not a bad idea with the extra column, however it only solves part of my issue. Imagine you have col(4) with 7 "1" right after each other and then followed by only "0's". Once you step down the rows with

csetvalue col:=col(3) formula:="col(4)[i+1]+col(4)[i+2]+col(4)[i+3]+col(4)[i+4]==4?1/0:col(3)" recalculate:=0;

only the first few points will be removed as you eventually will start to sum over some "0". I want to remove all 7 points. If only there were ex. 3 "1" appearing right after each other, then none of them should be removed. It's a bit tricky and I am not sure how to solve it.
Go to Top of Page

greg

USA
1378 Posts

Posted - 09/03/2014 :  09:35:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
// BEGIN SCRIPT
range raTarget = col(3), raTest = col(2);
count = 0; // Keep track of how many failed points
flag = 0; // Set to one when four sequence minimum is met
loop(ii,1,raTarget.GetSize())
{
switch(flag)
{
case 0:
if(raTarget[ii] >= raTest[ii] * 0.9) count++;
else count = 0;
if(count == 4) flag = 1;
break;
case 1:
if(raTarget[ii] >= raTest[ii] * 0.9) count++;
else
{
loop(idx,ii-count,ii-1)
{
raTarget[idx] = 0/0;
}
count = 0;
flag = 0;
}
}
}
// END SCRIPT
Go to Top of Page

Mats77sv

Sweden
10 Posts

Posted - 09/07/2014 :  5:11:14 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Greg,

Sorry for my late response. Yes your coding now Works perfect in my script. Thanks.
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