Author |
Topic  |
|
nebiha2006
Tunisia
Posts |
Posted - 07/28/2006 : 10:17:49 AM
|
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
|
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 |
 |
|
nebiha2006
Tunisia
Posts |
Posted - 07/28/2006 : 5:18:26 PM
|
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. |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 07/28/2006 : 8:24:54 PM
|
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 |
 |
|
nebiha2006
Tunisia
Posts |
Posted - 07/29/2006 : 06:55:09 AM
|
thank u |
 |
|
verrallr@a
Canada
44 Posts |
Posted - 08/10/2006 : 4:50:05 PM
|
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. |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 08/11/2006 : 07:31:14 AM
|
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 |
 |
|
|
Topic  |
|