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
 Calculate something from fit parameters
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

a.abc.b35

175 Posts

Posted - 11/15/2010 :  9:49:42 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I have written a fitting routine in origin 8.0. I have 3 parameters to it which are calculated after the best fitting of the model to the experimental data. Now I want to calculate another parameter from these + one result of the routine. Can anyone tell me how to do it ?
..
I have tried typing the equation in derived parameters tab but it does not give any result. If I type an equation there with only the input parameters and constants, than I get some result. But I am not able to get anything out if I use a result (stored to a variable) to that equation. Could anyone please help ?

AB

a.abc.b35

175 Posts

Posted - 11/15/2010 :  11:27:45 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
to add, i simply want to print the value of some parameters calculated inside the routine ? In c, printf and vprintf is supposed to work but I dont know how to use these or something else to extract the result from the routin . can someone please help quickly ?

AB
Go to Top of Page

Iris_Bai

China
Posts

Posted - 11/16/2010 :  05:10:58 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,


static int count = 0; // put this define outside _nlsf function

// put the following code inside function to print out the value of parameter A and B
printf("Index:%d  A=%f, B=%f\n", count++, A, B);


Please keep Scirpt Window is open. Choose menu Window -> Script Window to open it. The result will be outputed to this window.

Iris

Edited by - Iris_Bai on 11/16/2010 05:13:07 AM
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/21/2010 :  8:51:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks for the help. It worked one time but than it gives me the following error :
"Static Variables are not allowed in pre-compiled headers"
....
How do I solve it ?

AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/21/2010 :  9:49:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have included the following in the code:
1) static int count = 0; // before the "_nlsf" part just below
"#pragma warning(error : 15618)
#include <origin.h>
#include <oc_nag8.h>"
(i need the nag library as i am using an integrator from their to calculate my parameters)
..
2)Then inside "_nlsf" ,just before the last line, i have included the following :
"printf("Index:%d A = %f\n", count++, A);"

...
When I compile the code, it compiles perfectly. But when I go to the simulate curve part,nothing will show up (which use to show up without the above code) and in the script window i see the message :
"Static variables are not allowed in pre-compiled headers"
(this line repeats a lot of times!!!)
...
instead if I put both step 1) and 2) inside the "_nlsf" part,compile,and simulate, I get the following (the simulation is using 100 X points !):
" Index:0 A = 0.143846"
and this goes upto 100th line with
" Index:99 A = 0.143846".
If I simulate again,it'll repeat the same from Index = 100 to Index = 199 (it is clearly equal to the number of X points in the simulation)
.
If there is 3 X points,the index will go from 0 to 2 (say)
..
I want only one output line,with the value of A at the end of the simulation, or fitting, whichever I am doing.
Is it possible to do it Iris ?
Please help.


AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/22/2010 :  12:29:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
One more thing, Iris...hope you can help.
...
I have used the code builder to write a code. But I want to user input,on prompt,some parameters to it. I wanted to use 'cin' and 'cout' by including 'iostream' at the top for data input and output. But it says that the include file 'iostream' is not available !!!
...
So what shall be the work around ? I understand that iostream is not included with origin. But than how do i prompt the user for inputs ?
I can surely use 'printf' for output,as I have done here,based on your suggestion.

AB
Go to Top of Page

Iris_Bai

China
Posts

Posted - 11/22/2010 :  12:43:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by a.abc.b35

One more thing, Iris...hope you can help.
...
I have used the code builder to write a code. But I want to user input,on prompt,some parameters to it. I wanted to use 'cin' and 'cout' by including 'iostream' at the top for data input and output. But it says that the include file 'iostream' is not available !!!
...
So what shall be the work around ? I understand that iostream is not included with origin. But than how do i prompt the user for inputs ?
I can surely use 'printf' for output,as I have done here,based on your suggestion.

AB



Hi,

May be you can use InputBox function, this is an overloaded function to input double type numeric or text.

double InputBox( double dDefault, LPCSTR lpcszMsg = NULL )
string InputBox( LPCSTR lpcszMsg, LPCSTR lpcszDeault = NULL, DWORD dwOption = 0 )


There are other simple useful dialogs in Origin C, see http://ocwiki.originlab.com/index.php?title=OCGuide:Common_Dialog_Boxes


Iris
Go to Top of Page

larry_lan

China
Posts

Posted - 11/22/2010 :  01:59:46 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi:

In your first post, you said:

quote:
I have tried typing the equation in derived parameters tab but it does not give any result


Could you please show us how you defined the derived parameters? And how you defined your fitting function?

Regarding the question

quote:
I want only one output line,with the value of A at the end of the simulation


Maybe you can output the value in "Script After Fitting"? For example, Suppose your fitting function is:

void _nlsfMyLine(
// Fit Parameter(s):
double a, double b,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
	// Beginning of editable part
	y = a + b*x;
	// Put the value of a into LabTalk Global variable, MyFittedA
	LT_set_var("MyFittedA", a);
	// End of editable part
}

Then you can type the following script in "Script After Fitting" edit box:

MyFittedA = ;

Thanks
Larry
OriginLab
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/22/2010 :  11:26:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi there. I can't find Script after fitting in my version of origin 8.0 Pro. May be its not there. Does not matter. We can leave that.
I liked the InputBox global function for data input from user. I went to the link Iris posted and than wrote the following code in a file :
"#include <Origin.h>
void abc ()
{
// enter string
string strName = InputBox("Please enter your name", "");
printf("Name is %s.\n", strName);

// enter numeric
double dVal = InputBox(0, "Please enter a value");
printf("Value is %g.\n", dVal);
}"
When I compile it, I get errors :
"compiling...
abc.c
C:\..\abc.c(33) :Error, cannot convert argument in function call
C:\..\abc.c(40) :Error, cannot convert argument in function call
C:\..\abc.c(40) :Error, general compile error
C:\..\abc.c(33) :Error, error(s) found in compiling function abc

Compiling errors found, linking cannot start!"

...
I am kind of lost here. Could you please point out if I am doing anything wrong !

AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/22/2010 :  11:28:17 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
@ Larry,
I have dropped the idea of derived parameters. So don't worry about it.
And its a long code. We can forget about that !!!

AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/22/2010 :  3:57:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If I use only the string part, it works. But for the numeric part, the error is still there.

AB
Go to Top of Page

Iris_Bai

China
Posts

Posted - 11/22/2010 :  10:13:27 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by a.abc.b35

Hi there. I can't find Script after fitting in my version of origin 8.0 Pro. May be its not there. Does not matter. We can leave that.
I liked the InputBox global function for data input from user. I went to the link Iris posted and than wrote the following code in a file :
"#include <Origin.h>
void abc ()
{
// enter string
string strName = InputBox("Please enter your name", "");
printf("Name is %s.\n", strName);

// enter numeric
double dVal = InputBox(0, "Please enter a value");
printf("Value is %g.\n", dVal);
}"
When I compile it, I get errors :
"compiling...
abc.c
C:\..\abc.c(33) :Error, cannot convert argument in function call
C:\..\abc.c(40) :Error, cannot convert argument in function call
C:\..\abc.c(40) :Error, general compile error
C:\..\abc.c(33) :Error, error(s) found in compiling function abc

Compiling errors found, linking cannot start!"

...
I am kind of lost here. Could you please point out if I am doing anything wrong !

AB



Hi,

I copied the above abc function to one c file in Origin Code Builder, and then compile, no compiling and linking error, see:
compiling...
test.c
Linking...
Done!

Could you try to compile a very simple function?

#include <Origin.h>
void testok()
{
	out_str("Just a test");
}

If also failed, I guess your Origin is bad? Need to repair install Origin again.


Iris
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/23/2010 :  11:29:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I copied the above code and made the function. It works just fine !!

AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 11/23/2010 :  11:31:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
By the way, if I use only the following :
"
#include <Origin.h>
void abc ()
{
// enter string
string strName = InputBox("Please enter your name", "");
printf("Name is %s.\n", strName);
}

"
i.e., exclude the numeric part, it works just fine !!

AB

Edited by - a.abc.b35 on 11/23/2010 11:32:47 PM
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