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

cjk209

USA
7 Posts

Posted - 02/21/2014 :  6:26:53 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 9.0.0 SR2
Operating System: Windows 7

I am having great difficulty figuring out how to use Origin C to get the correct parameter initialization I need. I have very little experience with the C language.

So I have defined a user fitting function, say y = A*exp(k*x) and I have specified both A and k as parameters while x is my independent variable. In the Function Builder, under the Parameters tab I have specified k = 1 for initial value (not fixed) and A = "--" (nothing) and is fixed. I need parameter A to initialize as the 'yatxmax' value of my X&Y data of the active worksheet, but once it initializes it needs to become a fixed parameter.

Thus, for my initialization code I have tried the following:

Curve crv("Data1_A","Data1_B"); //hopefully this is the right code that says 'use data from column A and column B in active worksheet'
A = yatxmax(crv); //this should initialize A as yatxmax


Of course this doesn't work...It tells me that A is not properly initialized. That is probably because I used a "--" as the value in the Parameters tab. If I input a value in the Parameters tab it overrides the "yatxmax" initialization.

Is there some way I can use the initialization code to fix this parameter after 'yatxmax' initialization without checking the "Fixed" box in the Parameters tab in Function Builder?

Thanks for any help!



greg

USA
1378 Posts

Posted - 02/25/2014 :  12:19:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
You are over-thinking the fitting process. The fitter assigns the variables to the data so there is no need to hard-code a constructed curve:
Curve crv("Data1_A","Data1_B");

Within the fitter, we make available both the variables:
x_data, y_data
and the curve:
x_y_curve
which you can use within parameter initialization as needed.

We already have your function built-in ( Exp2PMod1 ), but your 'k' is our 'b'. Defining a function your way, with your parameter names makes sense, but you don't need to redefine the wheel since you can copy the Parameter Initialization code from Exp2PMod1:

int sign;
b = get_exponent(x_data, y_data, NULL, &a, &sign);
a = sign * exp(a);

and make a few small changes:

int sign;
k = get_exponent(x_data, y_data, NULL, &A, &sign);
A = sign * exp(A);

Note that C is case sensitive, so x, y, A and k case must match your definition. The above initialization code includes three instances of 'A' for example.
Go to Top of Page

cjk209

USA
7 Posts

Posted - 03/16/2014 :  5:08:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you!!!
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