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

nebiha2006

Tunisia
Posts

Posted - 07/28/2006 :  10:17:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin):
Operating System:
HI, i'm trying to search the heavyside function in the Origin Lab, but no result! does it exist as a function?
or else can u help me to program it?
thank u.

Mike Buess

USA
3037 Posts

Posted - 07/28/2006 :  10:36:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
As far as I know, Heaviside is merely the step function...

H(x) = 0 (x<0)
H(x) = 1 (x>0)

Programming example:
If column A contains the X values you can fill column B with Heaviside values like this...

col(B) = col(A) > 0 ? 1 : 0;

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/28/2006 10:59:58 AM
Go to Top of Page

nebiha2006

Tunisia
Posts

Posted - 07/28/2006 :  5:18:26 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
actually, the problem isn't to set a column value, but im doing a non linear curve fit, so i have to put an analytical expression in which there is the heavyside function, that's why i want to program this function
i did:
if (x<0) h(x)=0;
else h(x)=1;
y=(......)*h(x);
but it doesn't want to compile,
that's the main problem

thanks for help.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 07/28/2006 :  8:24:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The compiler is looking for an OriginC function called h(x) which doesn't exist. This should work assuming (....) is a sensible expression...

double h = 0;
if( x>0 ) h = 1;
y = (....)*h;


It's even easier than that...

if( x<0 ) y = 0;
else y = (....);

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 07/29/2006 2:32:47 PM
Go to Top of Page

nebiha2006

Tunisia
Posts

Posted - 07/29/2006 :  06:55:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thank u
Go to Top of Page

verrallr@a

Canada
44 Posts

Posted - 08/10/2006 :  4:50:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Or you can use Code Builder to establish Heavyside function thus,

double Heavyside(double x)
{if (x<0) return 0;
else return 1;}

and then put that function in the Systems directory (located on the left side of Code Builder).

That way the Heavyside function is started whenever you load Origin, and you can use it whenever you want. (You don't need to link it to another function, which you may not always want to use.)

Richard.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 08/11/2006 :  07:31:14 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Richard,

Adding the function to the System folder will not automatically make it available for use in other OC files. You must also prototype in each file...

double Heavyside(double);

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 08/11/2006 07:53:54 AM
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