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中文论坛
 Origin 中文论坛 (Chinese Origin Forum)
 自定义拟合函数编程求助
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

gll

China
1 Posts

Posted - 05/26/2019 :  10:27:03 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
您好,
请问在自定义拟合函数(dn/dt=-k1*n-k2*n^2-k3*n^3)时编译完成,无错误,但调用时会提示“未初始化的函数指针”。请问您知道这是什么原因吗?困惑好久,实在没有办法了,非常感谢。以下是我编写的代码:
void _nlsfFitODEFunc0(
// Fit Parameter(s):
double G, double k1, double k2, double k3, double ys,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y,
// Partial Derivative(s):
double& dy_G, double& dy_k1, double& dy_k2, double& dy_k3, double& dy_ys)
{
// Beginning of editable part
NLFitContext *pCtxt = Project.GetNLFitContext();
if (pCtxt) {
static vector vT, vY;
static matrix mY;
static int nSize;
BOOL bIsNewParamValues = pCtxt->IsNewParamValues();
if (bIsNewParamValues) {
int order = 1;
StringArray saEq;
saEq.Add("G-k1*y-k2*y^2-k3*y^3");
vector vP;
vP.Add(G=1);
vP.Add(k1=1);
vP.Add(k2=1);
vP.Add(k3=1);
vector vInt;
vInt.Add(2.);
vInt.Add(12.);
int np = 100;
vector vY0;
vY0.Add(0.000000);
int method = 1;
int rk = 1;
double tol = 1.e-005;
string fileName = GetOriginPath(ORIGIN_PATH_APPS_ROOT) + "Fit ODE\\FitODE.c";
p_ocmath_ode_app p_ocmath_ode_app_fun = Project.FindFunction("ocmath_ode_app_for_fdf", fileName, true);
if (p_ocmath_ode_app_fun(order, saEq, vP, vInt, np, vY0, method, rk, tol, vT, mY) < 0) {
return;
}
mY.GetColumn(vY, 0);
}
ocmath_interpolate(&x, &y, 1, vT, vY, vT.GetSize());
}
// End of editable part
}

yuki_wu

896 Posts

Posted - 05/27/2019 :  10:00:39 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

建议直接使用 Fit ODE App:
https://www.originlab.com/FileExchange/details.aspx?v=0&fid=500

Regards,
Yuki

OriginLab
Go to Top of Page

abufaisal6565

United Arab Emirates
9 Posts

Posted - 10/31/2021 :  10:06:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi
it seems the solution is written in Chinese language!
Could you help to get the solution for the nonlinear differential equations for many state variable with respect to time such as:
dy1/dt=k1y1 +

dy1/dt= k1y5 - k2*y1y2
dy2/dt=k2*y1 - k1*y2*y3
dy3/dt=k1*y2*y3 -k3*y3
where k1, k2,k3 are parameters to be estimated based on the output against observed data which leads to optimal fitting data?
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