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

nesrin9002

USA
2 Posts

Posted - 04/15/2014 :  9:51:14 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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.

nesrin9002

USA
2 Posts

Posted - 04/16/2014 :  1:22:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

greg

USA
1378 Posts

Posted - 05/01/2014 :  09:07:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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.
Go to Top of Page

long nguyen

Vietnam
1 Posts

Posted - 05/23/2014 :  9:23:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
it difficult to understand .

Go to Top of Page

MaggotsBrain

Japan
4 Posts

Posted - 05/25/2014 :  10:14:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
maybe this can help you: http://www.originlab.de/www/helponline/Origin/en/mergedProjects/Tutorial/Tutorial/User_Defined_Fitting_Function_using_OC.html
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