T O P I C R E V I E W |
aakanik |
Posted - 01/19/2017 : 02:34:28 AM Origin Ver: 8.5.0 SR1. Operating System: Windows 10
Hello everyone,
I am trying to gaussian fit a data using origin C. I have written codes for it and on compilation it's not showing any error. However, on running the codes I am getting error message "Parameter Init fail".
Codes I have written ask user to select a data file and then copy it in origin worksheet. After that for fitting I am pasting codes given in http://www.originlab.com/doc/OriginC/ref/NLFitSession-Fit#Examples On running the program it successfully asks user for data file and copies it in origin worksheet but it is not fitting that data and showing above mentioned error.
Kindly guide me how can I resolve this problem.??
Thanks in advance..!!
newuser |
12 L A T E S T R E P L I E S (Newest First) |
yuki_wu |
Posted - 01/23/2017 : 10:12:20 PM Hi,
1. If you want to get the fitted result, the GetYFromX method can help: http://www.originlab.com/doc/OriginC/ref/NLFitSession-GetYFromX
2. To calculate the area under the curve, please refer this page: http://www.originlab.com/doc/OriginC/ref/ocmath_integrate
In fact, all the value of parameter or statistics need to be accessed by Origin C function. If you want to do fitting more straightforward like GUI, you may like the X-Function xop: http://www.originlab.com/doc/X-Function/ref/xop
Regards, Yuki OriginLab |
aakanik |
Posted - 01/23/2017 : 04:26:55 AM Hello Yuki,
Thank you very much..!! After making modifications as per your suggestion, the codes work miraculously and I am getting proper fit.
I have one more doubt regarding fit, as per codes I am getting fitting and the results of fit too. But I want to read the values of fit(for eg: Area) and perform some calculations with that value. Then how can I read those values as an input value for further programming.?
Also, while we perform Gaussian fit in origin GUI, one more worksheet is created in original worksheet displaying results of the fit. If we want the same to be created via programming after fitting then how could it be done.??
newuser |
yuki_wu |
Posted - 01/21/2017 : 10:38:21 PM Hi Abha,
After checking your code, I found that you in fact do fitting at first and then import the data. That is to say, you actually do fitting on an empty worksheet. Therefore, the two vectors vx and vy did not fill with data so that you got the error message ”fail to init parameter”.
Just like cpyang's suggestion, you should check your data when you debug your code, for example, by setting breakpoints.
Please read more details in my mail.
Regards, Yuki OriginLab |
aakanik |
Posted - 01/20/2017 : 06:15:35 AM Hello,
okey..!! 
newuser |
yuki_wu |
Posted - 01/20/2017 : 05:51:33 AM Hi,
I received your mail just now. I will get back to you.
Regards, Yuki OriginLab |
aakanik |
Posted - 01/20/2017 : 04:34:02 AM Hello,
I have submitted the codes and data in the given link, but I am not sure whether the message has been send or not as I didnot get confirmation text showing message has been submitted.
In case if file has not submitted please inform, I will resend it.
Thank you..!! :)
newuser |
aakanik |
Posted - 01/20/2017 : 02:14:51 AM Hello,
Thank you for replying..
Yes I have modified code, as I have stated earlier I have first asked the user to choose an ASCII file and then I have performed fitting in user defined file.
Actually I have a spectrum with 5 peaks on which I want to perform Gaussian fitting. But before trying on it I am first trying to fit in one peak but on not getting results I am trying on same data as used in example. But Still I am not getting results.
I am pasting the data along with codes in the link given by you. Please have a look over it and help me out with pointing mistake I am doing and rectifying it.
Thank you in advance..!!
newuser |
yuki_wu |
Posted - 01/20/2017 : 01:48:01 AM Hi,
Did you modify the code of this example? Have you tried this example based on the exact steps? I have played with the example on my machine, but it worked okay.
From your screenshot, it seems that you modified the code instead of just copying and pasting. I think you may paste your code here, or contact the tech support for more help. You can find the contact information here: http://www.originlab.com/index.aspx?go=COMPANY/ContactUS
Regards, Yuki OriginLab
|
aakanik |
Posted - 01/20/2017 : 12:03:36 AM Hello,
As per your suggestion I rechecked after changing data values. I used same data as used in gaussian.dat in examples. Again I found same error.
For reference I am attaching two pictures that elaborate my problem. Please have a look over it.


newuser |
cpyang |
Posted - 01/19/2017 : 11:19:10 PM FitSession.SetData will take vx and vy, can you examine and verify that you have these two vectors properly filled with your data?
CP
|
aakanik |
Posted - 01/19/2017 : 11:06:45 PM Hello cpyang..!!
Thank you for quick replying. 
Manually I tried to fit data in origin GUI and I could do it easily and accurately but same if I am trying programatically then m getting errors. With program I could read ASCII file and copy it in origin worksheet but fitting could not be done. I tried playing with codes given in help hoping to get results, but I guess am terribly doing some mistake in codes and not able to figure it out.
For sake of checking I created Gaussian points by manually calculating from formula and then tried to fit it programatically, same error occurred. Fitting can be done on same data in origin GUI but if with program I am trying then it fails. 
newuser |
cpyang |
Posted - 01/19/2017 : 8:36:17 PM I suggest you first check your data. Run the fitting in Origin's GUI to fit one typical dataset and see if you run into issue. Parameter Init Fail is usually because you did not provide the proper XY data for the code to come up with proper values to initialize the parameters.
CP
|