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
 NLSF: fitting with multiple independent variables.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

bluecourse

China
Posts

Posted - 05/27/2007 :  01:10:49 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Version:Origin 7.5
Hello,
I would like to fit the following formula by origin c program.
Radiance=f(Normal,Camera,Light,Irradiance,Specular,Diffuse,Rough);
Independent Variables:Normal,Camera,Light,Irradiance
Fitting Parameters: Specular,Diffuse,Rough
Dependent Parameters: Radiance
I have surveied many examples in the forum and programming manual, I still cannot understand how to set many Independent Variables. Ath the same time, I can not understand how to use the methods nlsf.setDepend(VarName, Dataset)and nlsf.setIndep(VarName, Dataset).
Can anybody help me? Thanks a lot and waitting for the answer.

Mike Buess

USA
3037 Posts

Posted - 05/27/2007 :  03:37:06 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here are two examples of fitting with multiple (2) independent variables...
http://www.originlab.com/index.aspx?s=9&pid=434
quote:
I can not understand how to use the methods nlsf.setDepend(VarName, Dataset)and nlsf.setIndep(VarName, Dataset).
I've never been successful with those methods. Much easier to use nlsf.y$= "dependent dataset name" and nlsf.x1$ = "1st independent dataset name", nlsf.x2$ = "2nd independent dataset name", etc. A dataset name has the form wksName_columnName. If the independent variables are columns in wks Data1 with the column names Normal, Camera, etc., and dependent variable is column Radiance in same wks then the nlsf script will start out like this

nlsf.func$=MyFunction;
nlsf.x1$=Data1_Normal;
nlsf.x2$=Data1_Camera;
nlsf.x3$=Data1_Light;
nlsf.x4$=Data1_Irradiance;
nlsf.y$=Data1_Radiance;

where MyFunction might be defined something like this...



Mike Buess
Origin WebRing Member
Go to Top of Page

bluecourse

China
Posts

Posted - 05/27/2007 :  11:30:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot for your help and your kindness, Mike Buess San. I have programmed refer to your advice, but there are some new quesitons. In fact, I would like to fit formula like this:(Sorry ,I don't know how to paste picture.)
-------------------My Formula In [Edit Function]------------
Parameter Names: Rd, Gd, Bd, Rs, Gs, Bs, m
Indenpendent Var: Nx,Ny,Nz,Vx,Vy,Vz,Lx,Ly,Lz,Ir,Ig,Ib
Dependent Var:Rm,Gm,Bm
Formula (Just sketch representation and m is share parameter.):
f1(Nx,Ny,Nz,Vx,Vy,Vz,Lx,Ly,Lz, m);
Rm = f2(Rd, Rs, Ir, f1);
Gm =f2(Gd, Gs, Ig, f1);
Bm = f2(Bd, Bs, Ib, f1);
--------------------------------------------------------------------
This formula expression is correct and data is also correct, because I implemented nonlinear fitting by origin toolbar and got correct result. But I can't get correct fitting result by origin C program.
The following is my origin C program:
--------------------------My Program---------------------------
Worksheet wks = Project.ActiveLayer();
Dataset radianceR(wks,0);
Dataset radianceG(wks,1);
Dataset radianceB(wks,2);
Dataset normalx(wks,3);
Dataset normaly(wks,4);
Dataset normalz(wks,5);
Dataset camerax(wks,6);
Dataset cameray(wks,7);
Dataset cameraz(wks,8);
Dataset lightx(wks,9);
Dataset lighty(wks,10);
Dataset lightz(wks,11);
Dataset irradianceR(wks,17);
Dataset irradianceG(wks,18);
Dataset irradianceB(wks,19);

using NLSF = LabTalk.NLSF;
NLSF.begin();
NLSF.Init();
NLSF.msgPrompt=1;
NLSF.Output(0);
NLSF.Func$ = "Wand";
NLSF.p1=0.5;
NLSF.p2=0.5;
NLSF.p3=0.5;
NLSF.p4=0.1;
NLSF.p5=0.1;
NLSF.p6=0.1;
NLSF.p7=0.1;
NLSF.v1=1;
NLSF.v2=1;
NLSF.v3=1;
NLSF.v4=1;
NLSF.v5=1;
NLSF.v6=1;
NLSF.v7=1;
NLSF.xMode =2;
NLSF.y1$=radianceR.GetName();
NLSF.y2$=radianceG.GetName();
NLSF.y3$=radianceB.GetName();
NLSF.x1$=normalx.GetName();
NLSF.x2$=normaly.GetName();
NLSF.x3$=normalz.GetName();
NLSF.x4$=camerax.GetName();
NLSF.x5$=cameray.GetName();
NLSF.x6$=cameraz.GetName();
NLSF.x7$=lightx.GetName();
NLSF.x8$=lighty.GetName();
NLSF.x9$=lightz.GetName();
NLSF.x10$=irradianceR.GetName();
NLSF.x11$=irradianceG.GetName();
NLSF.x12$=irradianceB.GetName();

NLSF.constr$="0<Rd";
NLSF.constr$="0<Gd";
NLSF.constr$="0<Bd";
NLSF.constr$="0<Rs";
NLSF.constr$="0<Gs";
NLSF.constr$="0<Bs";
NLSF.constr$="0<m<1";
NLSF.constraints=1;

NLSF.Wtype = 0;
NLSF.ChiSqrErr = 0;
NLSF.Iterate(100);
NLSF.End(5);
--------------------------------------------------------------------
It's very strange that when I execute the program, it produce an attention dialog:
"*****Attention! New or modified functions have not be saved: Wand Modified function*****",
then I select "Save All" button. Then it start fitting process. But after a while, origin produce
another attention dialog:
"*****Attention! Error 28037. Likely caused by errors in user defined formula or poor parameter initialization*****".
I'm ensure that the formula is correct and data is correct. I believe that there are come errors in Origin C program, I have tried many times buy still unkown the reasons.
Any kind help or advice will be appreciated. Thank you all.


Edited by - bluecourse on 05/27/2007 12:08:21 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