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
 Origin Forum
 reverse dataset order
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

celarson

USA
8 Posts

Posted - 04/25/2003 :  4:53:53 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Is there a simple way to reverse(invert?) the order of data in a column? If I have 1,5,3,5,2 in rows 1..5 to start I want the order to be 2,5,3,5,1 when I'm done.

Right now I create another column, fill with row numbers and desending sort that to flip my data but that seems rather clunky. As always, apprecation for help on my simple questions.

Mike Buess

USA
3037 Posts

Posted - 04/26/2003 :  08:02:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The following Origin C function copies the selected column to a one-row matrix, flips the matrix horizontally and copies the data back to the column. It may sound like a roundabout approach but it works fine.

void InvertColumn()
{
Worksheet wks=Project.ActiveLayer();
int c1,c2,r1,r2;
if( wks.GetSelection(c1,c2,r1,r2) != 26 ) return;

Dataset dd(wks,c1);
matrix mm(1,r2+1);
mm.SetByVector(dd);
mm.FlipHorizontal();
mm.GetAsVector(dd);
}

If you don't have Origin 7 you can write a LabTalk macro/script that does what you do now.

Mike Buess
Origin WebRing Member
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