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
 Forum for Origin C
 Sort X Y dataset
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

peter.cook

UK
356 Posts

Posted - 09/03/2004 :  11:14:51 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

Can anyone please tell me how to sort an X-Y dataset eg created by 'create petesdata -c 10'. I can only think of a way using data_sort but I seem to have to copy data to a worksheet first in order to perform this fuction. I would really like to avoid this.

Cheers,

Pete

cpyang

USA
1406 Posts

Posted - 09/03/2004 :  11:50:04 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Use Curve, as can be seen below


void dd()
{
LT_execute("create petesdata -c 5");
LT_execute("petesdata = {1,2,3,4,5}");
LT_execute("petesdata_a = {2,3,4,5,1}");

Curve cc("petesdata_a", "petesdata");
cc.Sort();
for(int ii = 0; ii < cc.GetSize(); ii++)
{
printf("%d:%f\n", ii+1, cc[ii]);
}
}





CP


Go to Top of Page

peter.cook

UK
356 Posts

Posted - 09/03/2004 :  12:03:34 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks CP!

I hadn't browsed/scrolled through the help properly.

Cheers,

Pete

Go to Top of Page

peter.cook

UK
356 Posts

Posted - 09/03/2004 :  12:26:51 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi CP,

A problem I had was that OCSortXYDataSet fitcol$(ng)_a fitcol$(ng); doesn't work. I had to use %T=fitcol$(ng); OCSortXYDataSet %T_a %T;

Why is this?

Thanks,

Cheers,

pete

Go to Top of Page

cpyang

USA
1406 Posts

Posted - 09/03/2004 :  12:53:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I think that was never supported, as long as you can see the work around, better just do that. With string variables, those %T etc should no longer be used to hold anything other than a temp variable. I understand in the past, many of such %T, %M etc might be holding longer term values that prevented them from being used anywhere to just as a temp variable.

CP


Go to Top of Page

peter.cook

UK
356 Posts

Posted - 09/03/2004 :  2:39:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Thanks for reply. I do use eg %T for temp variables. Can use workaround now I know. The particular example was using multiple graphs and fitcol$(ng) referred to curve data for each graphs eg ng=1 to 12.

Cheers,

pete

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