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
 All Forums
 Origin Forum
 Origin Forum
 Fitting 2 equations to different ranges of x

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
CMcRitchie Posted - 07/28/2016 : 08:37:47 AM
Hi,

I wondered if it was possible to use the Fitting Function Organiser in the following way:

Using x,y data where 0<x<2000

Create a function that applies two or more equations to the experimental data over different ranges of x

e.g. Equation 1: y = a + (b*x) where 0<x<40

Equation 2: y = a + (b*x) where 40<x<2000

I know I can manually select different parts of the experimental data and apply each function in turn, however it would be really beneficial for me if this could be done using a user created function.

Any help would be much appreciated,

Thanks
5   L A T E S T    R E P L I E S    (Newest First)
Hideo Fujii Posted - 07/28/2016 : 11:15:45 AM
Hi CMcRitchie,

> if (x<x0) y=function1(x);
> if (x0<=x<=xa) y=function2(x);
> else y=function3(x);
> what is the correct command for the 2nd line?
> I assume repeating "if" is not correct.

The syntax should be like (assuming function type is Origin C):
if(x<x0)      y=function1(x);  //x<x0
else if(x<xa) y=function2(x);  //x0<=x<xa
else          y=function3(x);  //xa<=x
Hope this helps.

--Hideo Fujii
OriginLab

CMcRitchie Posted - 07/28/2016 : 10:59:02 AM
quote:
Originally posted by Hideo Fujii

Hi CMcRitchie,

> Do you know if there is a similar alternative that would accommodate non-linear functions?

Currently, there is no built-in piecewise non-linear functions. So, you need to make a user-defined function
generally in the following way:
y0=function1(x0);
if( x<x0 )  y=function1(x);
else	    y=function2(x); //function2 is a curve which passes (x0,y0) to connect to function1

The hard (if not impossible) part may be to find the form of function2 by solving y0=function2(x0) analytically.

Good luck.

--Hideo Fujii




Again thanks for your help. I have started to play around with using 2 equations, if I were to introduce a third equation, what do I write as the code to introduce an additional condition on the range of x? i.e. go from PWL2 to PWL3

e.g.

if (x<x0) y=function1(x);
if (x0<=x<=xa) y=function2(x);
else y=function3(x);

what is the correct command for the 2nd line? I assume repeating "if" is not correct.

Many thanks,

CMcRitchie
Hideo Fujii Posted - 07/28/2016 : 10:48:58 AM
Hi CMcRitchie,

> Do you know if there is a similar alternative that would accommodate non-linear functions?

Currently, there is no built-in piecewise non-linear functions. So, you need to make a user-defined function
generally in the following way:
y0=function1(x0);
if( x<x0 )  y=function1(x);
else	    y=function2(x); //function2 is a curve which passes (x0,y0) to connect to function1

The hard (if not impossible) part may be to find the form of function2 by solving y0=function2(x0) analytically.

Good luck.

--Hideo Fujii
CMcRitchie Posted - 07/28/2016 : 10:06:52 AM
quote:
Originally posted by Hideo Fujii

Hi CMcRitchie,

I think you can consider the built-in functions in the Piecewise category such as PWL2 for two segments
(or PWL3 for three segments):

http://www.originlab.com/doc/Origin-Help/PWL2

Please take a look.

--Hideo Fujii
OriginLab



Hi Hideo Fujii,

Thanks for your suggestion. Do you know if there is a similar alternative that would accommodate non-linear functions?

Thanks,

CMcRitchie
Hideo Fujii Posted - 07/28/2016 : 09:50:20 AM
Hi CMcRitchie,

I think you can consider the built-in functions in the Piecewise category such as PWL2 for two segments
(or PWL3 for three segments):

http://www.originlab.com/doc/Origin-Help/PWL2

Please take a look.

--Hideo Fujii
OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000