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 for Programming
 Forum for Origin C
 Fitting a plot using a user defined function

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
nesrin9002 Posted - 04/15/2014 : 9:51:14 PM
Hi,
Can someone help me with this;
I am trying to write user defined function to fit my plot.

The equation I have to fit is z=Sum{z_n * Sin(n*x)}
summation is over n, from lets say 0 to N.
x(angles) is the values on the x axis in my plot.

Thanks,
Nesrin.

4   L A T E S T    R E P L I E S    (Newest First)
MaggotsBrain Posted - 05/25/2014 : 10:14:43 PM
maybe this can help you: http://www.originlab.de/www/helponline/Origin/en/mergedProjects/Tutorial/Tutorial/User_Defined_Fitting_Function_using_OC.html
long nguyen Posted - 05/23/2014 : 9:23:04 PM
it difficult to understand .

greg Posted - 05/01/2014 : 09:07:17 AM
I am not sure how your second post relates to the first.
In the second you declared two arrays of double (c & d) which you did not initialize (so they are all zero).
Even if you fixed that, your use of each array ( c[2*i+1] and d[2*i] ) over the range i = 1 to 10 would produce indices which were out of bounds of the arrays.
nesrin9002 Posted - 04/16/2014 : 1:22:44 PM
So far I have this:

void _nlsfsum(
// Fit Parameter(s):
double y0,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double c[11];
double d[11];
for(int i=1; i<=10; i++)
{

y=y0+c[2*i+1]* sin((2*i+1)*x) + d[2*i]* cos(2*i*x);



}

It compiles but doesn't work when I fit it to the data.

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