24小时热门版块排行榜    

查看: 1327  |  回复: 1

agnes7777

银虫 (初入文坛)

[求助] 请教大家使用 OriginLab 做Fitting with Convolution 无法Fitting with compiling 已有1人参与

   跟着https://www.originlab.com/doc/Tutorials/Fitting-Convolution Fitting with Convolution把代码拷入后, 提示错误

Linking...
Done!
compiling...
_nlfFitConv.fit
.......TMP\OriginC\NLSF\_nlfFitConv.fit(42) :Error, Member's access requires struct/class type.
.......TMP\OriginC\NLSF\_nlfFitConv.fit(42) :Error, error(s) found in compiling method
.......TMP\OriginC\NLSF\_nlfFitConv.fit(42) :Error, general compile error
.......TMP\OriginC\NLSF\_nlfFitConv.fit(29) :Error, error(s) found in compiling function _nlsfFitConv


Compile Failed!

求大神帮忙 谢谢

---------------------------------------------
CODE:
   #pragma warning(error : 15618)
#include <origin.h>
// Header files need to be included
#include <ONLSF.H>
#include <fft_utils.h>
//
//
void _nlsfTestConv(
// Fit Parameter(s):
double y0, double A, double t,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
        // Beginning of editable part       
        NLFitContext *pCtxt = Project.GetNLFitContext();
        Worksheet wks;
        DataRange dr;
        int c1,c2;
        dr = pCtxt->GetSourceDataRange(); //Get the source data range
        dr.GetRange(wks, c1, c2);  //Get the source data worksheet
        if ( pCtxt )
        {       
                // Vector for the output signal in each iteration.
                static vector vSignal;
                // If parameters were updated, we will recalculate the convolution result.
                BOOL bIsNewParamValues = pCtxt->IsNewParamValues();
                if ( bIsNewParamValues )
                {
                        // Read sampling and response data from worksheet.
                        Dataset dsSampling(wks, 0);
                        Dataset dsResponse(wks, 2);
                        int iSize = dsSampling.GetSize();
                       
                        vector vResponse, vSample;
                       
                        vResponse = dsResponse;
                        vSample = dsSampling;

                        vSignal.SetSize(iSize);
                        vResponse.SetSize(iSize);
                        vSample.SetSize(iSize);
                       
                        // Compute the exponential decay curve
                        vSignal = A * exp( -t*vSample );
                        // Perform convolution
                        int iRet = fft_fft_convolution(iSize, vSignal, vResponse);
                        //Correct the convolution by multiplying the sampling interval
                        vSignal = (vSample[1]-vSample[0])*vSignal;

       
                }
               
                NLSFCURRINFO    stCurrInfo;
                pCtxt->GetFitCurrInfo(&stCurrInfo);
                // Get the data index for the iteration
                int nCurrentIndex = stCurrInfo.nCurrDataIndex;
                // Get the evaluated y value
                y = vSignal[nCurrentIndex] + y0;
                // For compile the function, since we haven't use x here.
                x;
        }
        // End of editable part
}

[ Last edited by jjdg on 2018-2-19 at 08:48 ]
回复此楼

» 猜你喜欢

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dingd

铁杆木虫 (职业作家)

【答案】应助回帖


感谢参与,应助指数 +1
jjdg: 金币+1, 感谢参与 2018-02-19 08:48:14
拟合问题推荐换用1stOpt,比Origin易用,效果也更好。
2楼2018-02-17 10:08:35
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 agnes7777 的主题更新
信息提示
请填处理意见