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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Run NLSF only from code

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
michaelbraun Posted - 07/11/2015 : 01:38:47 AM
Origin Ver. and Service Release (Select Help-->About Origin): 2015 sr2
Operating System:Windows

Hi, I have written a code which imports a dataset, plots it, allows the user to select a portion, and then fits an origin defined function. My question is how can I incorporate the run.LoadOC(originlab\nlsf_utils.c) line into my actual originc code without having to separately run this line in the command prompt before hand? I have tried

#include <originlab\nlsf_utils.c>;

and

LT_execute("run.LoadOC(Originlab\nlsf_utils.c)");

but neither works?
4   L A T E S T    R E P L I E S    (Newest First)
michaelbraun Posted - 07/11/2015 : 12:39:29 PM
It works now, thank you! I was not understanding how to correctly add the nlsf_utils.c file to my workspace. For anyone else having this problem, it is simply right clicking on the System folder in the left workspace panel of the Code Builder, add file, navigate to the OriginLab folder in your program files, navigating to the nlsf_utils.c file and opening it. With that added, the following header and fitting works:

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>
#include <..\originlab\nlsf_utils.h>
#include <..\originlab\NLFitSession.h>

                        //Fit gaussian to peak
			NLFitSession nlfSession;
			nlfSession.SetFunction("Gauss");
			nlfSession.SetData(yData,xData);
			nlfSession.ParamsInitValues();
			nlfSession.GetChiSqr();
			int     nOutcome;
			nlfSession.Fit(&nOutcome);
			
			// get parameter values after initialization
			vector vParamValues, vErrors;
			nlfSession.GetFitResultsParams(vParamValues, vErrors);    
 
			// output parameter values with names
			vector<string> vsParamNames;
			nlfSession.GetParamNamesInFunction(vsParamNames);   
 
			int         nDataset = 0;
			for( int nParam = 0; nParam < vParamValues.GetSize(); nParam++)
			{
				printf("%s = %f\n", vsParamNames[nParam], vParamValues[nParam]);
			}

Castiel Posted - 07/11/2015 : 12:06:53 PM
quote:
Originally posted by michaelbraun

Ah yes, sorry, I forgot the .. when I retyped it. The code you gave looks like it almost works, but I get a syntax error in variable declaration from the line
pfn_get_category_list(vsCategories, vnSeparatorIndices);

The following is my current header as I have tried to implement your code.

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>
typedef int (*FUN_GET_CATEGORY_LIST)(vector<string>& vsCategorys, vector<int>& vnSeparatorIndices = NULL);
FUN_GET_CATEGORY_LIST pfn_get_category_list = Project.FindFunction("nlsf_get_category_list", "originlab\\nlsf_utils.c", true);
pfn_get_category_list(vsCategorys, vnSeparatorIndices);
#include <..\originlab\NLFitSession.h>

And I get the same error for the third line you gave regardless if your three code lines are above or below the line
#include <..\originlab\NLFitSession.h>




It's something like
#include <..\OriginLab\nlsf_utils.h>
typedef int (*FUN_GET_CATEGORY_LIST)(vector<string>& vsCategorys, vector<int>& vnSeparatorIndices = NULL);
void test_nlsf() {
    FUN_GET_CATEGORY_LIST pfn_get_category_list = Project.FindFunction("nlsf_get_category_list", "originlab\\nlsf_utils.c", true);
    vector<string> vsCategories;
    vector<int> vnSeparatorIndices;
    pfn_get_category_list(vsCategories, vnSeparatorIndices);
}


However, now that you also need NLFitSession, there are likely more ploblems waiting for you....YOU'D BETTER ADD THE nlsf_utils.c TO YOUR ORIGIN C WORKSPACE -> SYSTEM, IN CODE BUILDER. THEN YOU DON'T HAVE TO TYPEDEF ANY MORE...

©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦
michaelbraun Posted - 07/11/2015 : 11:30:51 AM
Ah yes, sorry, I forgot the .. when I retyped it. The code you gave looks like it almost works, but I get a syntax error in variable declaration from the line
pfn_get_category_list(vsCategories, vnSeparatorIndices);

The following is my current header as I have tried to implement your code.

#include <Origin.h>
#include <..\OriginLab\theme_utils.h>
#include <GetNBox.h>
typedef int (*FUN_GET_CATEGORY_LIST)(vector<string>& vsCategorys, vector<int>& vnSeparatorIndices = NULL);
FUN_GET_CATEGORY_LIST pfn_get_category_list = Project.FindFunction("nlsf_get_category_list", "originlab\\nlsf_utils.c", true);
pfn_get_category_list(vsCategorys, vnSeparatorIndices);
#include <..\originlab\NLFitSession.h>

And I get the same error for the third line you gave regardless if your three code lines are above or below the line
#include <..\originlab\NLFitSession.h>
Castiel Posted - 07/11/2015 : 10:31:18 AM
quote:
Originally posted by michaelbraun

Origin Ver. and Service Release (Select Help-->About Origin): 2015 sr2
Operating System:Windows

Hi, I have written a code which imports a dataset, plots it, allows the user to select a portion, and then fits an origin defined function. My question is how can I incorporate the run.LoadOC(originlab\nlsf_utils.c) line into my actual originc code without having to separately run this line in the command prompt before hand? I have tried

#include <originlab\nlsf_utils.c>;

and

LT_execute("run.LoadOC(Originlab\nlsf_utils.c)");

but neither works?



  • Isn't it #include <..\OriginLab\nlsf_utils.c>? But I'm afraid that's a BAD idea to include the source code file instead of the header file....

  • Say, to call the nlsf_get_category_list(vector<string>& vsCategorys, vector<int>& vnSeparatorIndices = NULL), you may first
    typedef int (*FUN_GET_CATEGORY_LIST)(vector<string>& vsCategorys, vector<int>& vnSeparatorIndices = NULL);
    then
    FUN_GET_CATEGORY_LIST pfn_get_category_list = Project.FindFunction("nlsf_get_category_list", "OriginLab\\nlsf_utils.c", true);
    and finally
    pfn_get_category_list(vsCategorys, vnSeparatorIndices);


©c¡Ï   ¤È¥¹  ©f¨u©c  ©c¥ì    ¥Î¤³  ©c/     ©¦£¯
 ©c¨Ê¥Î ¤´¥¨  ¥ó ¨×   ¥ó¤á' ¥Ì©¦¥­   /¤í  ¥Õ©¦©f
   ¨Ö             ¦á          ©¦£þ  ©` ¥Õ   ©¦
                              ©¦

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000