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
 Delete data below certain length

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
AliceInNanoland Posted - 09/05/2017 : 09:45:00 AM
Origin Ver. and Service Release (Select Help-->About Origin): 2016 (64bit) Sr2
Operating System: Windows 8.1

I have data of trajectories and would like to delete those trajectories that are shorter than a certain threshold.
My raw data contains 3 columns: x and y coordinates and another column that specifies the trajectory number, e.g.

Table 1
traject x y
1 155.006 106.805
1 155.117 107.313
2 84.284 164.696
2 84.482 163.961
2 84.306 164.881
2 84.979 164.756
2 84.958 165.243
3 162.371 219.024
3 161.802 218.693
3 161.633 218.296
4 211.152 227.07
4 211.43 228.763
4 211.291 228.906
4 212.383 228.686
4 211.597 227.746
4 210.911 229.137

I can unstack the columns according to the trajectory number like this:

Table 2
x y x y x y x y
1 1 2 2 3 3 4 4
155.006 106.805 84.284 164.696 163.132 218.51 211.152 227.07
155.117 107.313 84.482 163.961 163.45 219.063 211.43 228.763
84.306 164.881 162.464 218.66 211.291 228.906
84.979 164.756 212.383 228.686
84.958 165.243 211.597 227.746
210.911 229.137

But I don't need the shorter trajectories, e.g. trajectories 1 and 3 that have only 3 or fewer rows.
Is there a possibility to either delete the rows of these trajectories in Table 1 or to delete the columns of these trajectories in Table 2?

I'm not very experienced with Origin yet and I've been picking the longer trajectories out of thousands of trajectories by hand which is very very tedious...therefore, I would be happy if anyone could help me!

PhD Student
Institute of Chemistry and Biochemistry
Freie Universität Berlin
3   L A T E S T    R E P L I E S    (Newest First)
AliceInNanoland Posted - 09/14/2017 : 11:54:31 AM
Dear Hideo Fujii, thanks for the quick reply. It works, thank you!

PhD Student
Institute of Chemistry and Biochemistry
Freie Universität Berlin
Hideo Fujii Posted - 09/05/2017 : 2:21:48 PM
Hi AliceInNanoland and visitors to this thread,

This is an addendum to my previous post. Although probably it doesn't matter in this specific situation for
the unstacked result, if the column contains missing values at the end of the dataset, rr.getSize() would return
the inflated value. To avoid such case, and to get the "actual" dataset size, you may want to define a function
like:
function double getActualSize(range ra) {
  int icnt, irow=ra.getSize();
  for(icnt=irow; icnt>=1; icnt--) if(ra[icnt]$!="" && ra[icnt]$!="--") break;
  return icnt;
}
Then, the code could be written like:
colthresh=3;  //threshold
nc=wks.nCols;
for(ii=nc; ii>=1; ii--) {
  range rr=wcol(ii); 
  if(getActualSize(rr)<=colthresh) del wcol(ii); //delete if shorter than threshold
}
Hope this suggestion helps in some situations.

--Hideo Fujii
OriginLab
Hideo Fujii Posted - 09/05/2017 : 11:07:32 AM
Hi AliceInNanoland,

Maybe the following code can do such job. Please try.
colthresh=3;  //threshold
nc=wks.nCols;
for(ii=nc; ii>=1; ii--) {
  range rr=wcol(ii); 
  if(rr.getSize()<=colthresh) del wcol(ii); //delete if shorter than threshold
}
Hope this helps.

--Hideo Fujii
OriginLab

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