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
 problems about "Set Columns Values"
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hfkenny

China
Posts

Posted - 12/18/2006 :  05:23:38 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: WinXP

Dear all:

I got 2 problems about "Set Columns Values":

1. Is it possible to set a column values according to the values of another column? Saying, the values of column B will be 0 when the values of column A is negaetive and vise versa.(row by row)

2. How can I associate my own C code with "add function" button? or how can I add a new function of my own into the "add function" downlist?


Thanks!!

hfkenny

Mike Buess

USA
3037 Posts

Posted - 12/18/2006 :  06:52:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
hfkenny,

1. Use the ternary operator. This sets col(B) to value1 if col(A)<0 and value2 otherwise.

col(B) = col(A)<0 ? value1 : value2

2. You can't add you function to the Add Function list but you can use it in the Set Column Values expression anyway as long as it's compiled...

col(B) = MyFunction(col(A));

Mike Buess
Origin WebRing Member
Go to Top of Page

hfkenny

China
Posts

Posted - 12/18/2006 :  9:21:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear Mike:

I tryed the ternary operator and it indeed works! I wonder how you can know this! Could you please give me some clue to find a comprehensive usage handbook about Origin? Anyway, Thank you very much for your help and I also give my best wish to you for the coming Christmas and New year!

hfkenny


Go to Top of Page

zachary_origin

China
Posts

Posted - 12/18/2006 :  9:50:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi hfkenny,

Mike knows so many deep things of Origin because he has used it for more than ten years. He almost knows everything for Origin... :)

To be familiar with Origin, I think the most useful handbook is the Help file in Origin though it contains many many chapters...

Zachary
OriginLab Technical Services.
Go to Top of Page

Leo_Li

China
Posts

Posted - 12/18/2006 :  11:31:06 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try this tutorial:

Origin Menu: Help->Tutorial
Tutorial 15: Adding a New Function (and call it in "Set Col Values" dialog)

Leo

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 12/19/2006 :  09:59:03 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks, Zachary... flattery will get you everywhere. :) The ternary operator is indeed in the programming guide.

LabTalk Language Reference > Overview... > Operators > Conditional Operators

There Origin's tReplace function is also discussed. It is more powerful and faster than the ternary operator but is also more difficult to use.

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 12/19/2006 09:59:50 AM
Go to Top of Page

hfkenny

China
Posts

Posted - 12/21/2006 :  05:02:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Dear all:

Thank you for your kind reply.

I've got a new problem now. When calculation of "arctan(a/b)", the result has to be modified according to the value of b: if b>0, no modification is needed; if b<0, the result should be added with pi(3.14159),and if b=0, then the value of "a" should be taken into consideration: a>0, the result should be +pi/2; a<0, the result be -pi/2 ,and a=0, a missing number. How can I realise this in "set column values"? I tried treplace function and it seems not to work.

hfkenny
Go to Top of Page

zachary_origin

China
Posts

Posted - 12/21/2006 :  05:36:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,
You may use the method 2 Mike has suggested. Leo has mentioned a tutorial for how to add a funtion.

Zachary
OriginLab Technical Services.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 12/21/2006 :  09:15:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi hfkenny,

tReplace acts on an entire dataset and will not work in a Set Column Values expression. You must use it from the script window.

Mike Buess
Origin WebRing Member
Go to Top of Page

hfkenny

China
Posts

Posted - 12/23/2006 :  10:08:52 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,Mike:

I tried "treplace" function and found it can work in a "Set Column Values" expression. you can try the example listed under "programming / tReplace" item. But this seem no help to my problem.

hfkenny
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