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
 Remove 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 - 05/11/2015 :  4:45:43 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.1pro
Operating System:win7

Hi,

In columns A and B I have a more than 200000 recorded data points and from time to time I get a sequence of identical data values. If I get a sequence of 6 or more similar data values, then I want to remove all point in the sequence except of one! So fare I have used a piece of a script that almost work - but not quite good enough as it also remove a few additional data points just before the "bad" sequence starts (see script below):


range raTarget = col(A), raTest = col(A);
count = 0;
flag = 0;
loop(ii,1,raTarget.GetSize())
{
switch(flag)
{
case 0:
if(raTarget[ii+1] >= raTest[ii]) count++;
else count = 0;
if(count == 6) flag = 1;
break;
case 1:
if(raTarget[ii+1] >= raTest[ii]) count++;
else
{
loop(idx,ii-count,ii-1)
{
raTarget[idx] = 0/0;
}
count = 0;
flag = 0;
}}}
range raTarget = col(B), raTest = col(B);
count = 0;
flag = 0;
loop(ii,1,raTarget.GetSize())
{
switch(flag}
{
case 0:
if(raTarget[ii+1] >= raTest[ii]) count++;
else count = 0;
if(count == 6) flag = 1;
break;
case 1:
if(raTarget[ii+1] >= raTest[ii]) count++;
else
{
loop(idx,ii-count,ii-1)
{
raTarget[idx] = 0/0;
}
count = 0;
flag = 0;
}}}

I also have a column C only listed with "1". If I could 'flag' the sequence of bad points by changing the related row values in column C to "0", then I could easily remove the points. But how do I get so far?

/Mats

JacquelineHe

287 Posts

Posted - 05/12/2015 :  04:48:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Mats,

1. Maybe because the following loop script in Case 1, so a few data will become missing value when you run your script.

loop(idx,ii-count,ii-1)
{
raTarget[idx] = 0/0;
}


2. If I do not misunderstand your meaning, you want to store the "flat" value for each loop, you can use:
Col(C)[ii]=flag;


Then use the loop script to delete the data if the corresponding "flat" value=0. For example:

range raTarget = col(A);
loop(ii,1,raTarget.GetSize())
{
range aa=1[$(ii)];
double bb=col(3)[$(ii)];
if (bb==0) del aa;
}

Please note: This script just delete the data in Column A (Column1), and shift cells up. So after run it the corresponding relation of Column A data and the Column C "flat" will be broken.

Thanks
Jacqueline
Originlab

Edited by - JacquelineHe on 05/12/2015 04:56:06 AM
Go to Top of Page

Mats77sv

Sweden
10 Posts

Posted - 05/14/2015 :  6:23:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Jacqueline,

Thanks for trying to help me and sory for my late answer. However, your suggestion will not work for me - sorry. Actually, I have 14 columns and more than 200000 data lines. My problem with the sequence of similar data values is only found in two columns – let’s call then A and B. If I delete the data values as suggested and shift up the data I will lose the connection to all the other columns.
So fare I have tried using the script I showed previously and then used the "csetvalue" command to delete the entire data line - not shifting up the row. However, the script, as it is now, also deletes the two data values found just before the start of the sequence of trouble data. That I do not know how to fix.
So basically I am trying to make a script that deletes a sequence of 6 similar values in a specific column. The 6 data values must appear right after each other otherwise they should not be deleted.
I really really hope you can help med :-)

\Mats

Go to Top of Page

lkb0221

China
497 Posts

Posted - 05/18/2015 :  11:48:25 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi, Mats

I think it will be better if you can share a piece of data so we can play with it. You can send to <tech@originlab.com>.


Zheng
OriginLab
Go to Top of Page

Mats77sv

Sweden
10 Posts

Posted - 05/18/2015 :  5:49:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Zheng,

I will sent some data to play with - thanks again.

\Mats
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