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
 flip a column
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

G.Bartsch

Germany
Posts

Posted - 11/17/2006 :  07:31:48 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
what is the best way to flip a column? i mean making the former first value the last, the second the one before the last and so on...
thanks

Mike Buess

USA
3037 Posts

Posted - 11/17/2006 :  08:38:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This LabTalk script flips the first selected column...

if( !selC1 ) return;
get %(%H,selC1) -e npt;
if( !npt ) return;
wks.AddCol();
%(%H,wks.ncols) = data(1,npt);
sort -cd selC1 selC1 %(%H,wks.ncols);
del %(%H,wks.ncols);


This Origin C function flips all selected columns...
void flip_selected_columns()
{
Worksheet wks = Project.ActiveLayer();
vector<int> vv;
wks.GetSelectedColumns(vv);
int nSels = vv.GetSize();
if( !nSels ) return;
for(int ii; ii<nSels; ii++)
{
Dataset dd(wks,vv[ii]);
matrix mm(dd.GetSize(),1);
mm.SetByVector(dd);
mm.FlipVertical();
mm.GetAsVector(dd);
}
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 11/17/2006 08:52:38 AM
Go to Top of Page

G.Bartsch

Germany
Posts

Posted - 11/17/2006 :  10:54:36 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thank you very much! works fine. nevertheless i assumed there was a more direct way, maybe one should implement something like that in later origin versions.
Go to Top of Page

stuzer

1 Posts

Posted - 12/05/2011 :  11:31:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK, another way:

You want to flip column A.
Mark an empty column -> right click -> set column values ->
write this: Col(A)[N+1-i]
N is a number of rows in column you want to flip.
Go to Top of Page

easwar

USA
1965 Posts

Posted - 12/09/2011 :  10:05:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

In 8.51 or later, there is a colreverse function.

In GUI, select a col (or a range or rows), then right click and select "Reverse Order" from the context menu.

From LabTalk script, you can run the XF associated with this menu, such as:

range r=1[5:10]; // col 1, rows 5 thru 10
colreverse r;


Easwar
OriginLab
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