T O P I C R E V I E W |
flirt |
Posted - 04/18/2005 : 4:41:08 PM Origin Version (Select Help-->About Origin): 7.5 Operating System: win2000
I'm following the tutorials and found that in tutorial 11, "Fitting using tools", the answer given by the script window is not the same as in the tutorial. I basically follow what the tutorial says. Then I tried another sample myself and use the script window to find x or y, again the answer is not right. If I tried several times, the answer given each time is different. Anybody ever encounter this? |
4 L A T E S T R E P L I E S (Newest First) |
flirt |
Posted - 04/19/2005 : 8:05:33 PM what a shame...... thx a lot. |
easwar |
Posted - 04/19/2005 : 5:43:27 PM Hi,
First of all the compile error you got is due to mismatched left and right parantheses. When you get a compile error, you can click the "Edit in Code Builder" button in the NLSF tool, which then opens the fitting function in Code Builder. You can then click the compile button in there and then double-click on the error line which will then place the cursor at the line that has the error.
In this case, the code should be corrected to:
double B1 = A1 / (0.5 * (sig1 + sig2) * sqrt(2 * pi)); double B2 = A2 / (0.5 * (sig3 + sig4) * sqrt(2 * pi)); if( x < xc1 ) y = y0 + B1 * exp(-0.5 * ((x - xc1) / sig1) ^ 2); else if( x < xc2 ) y = y0 + B1 * exp(-0.5 * ((x - xc1) / sig2) ^ 2) + B2 * exp(-0.5 * ((x - xc2) / sig3) ^ 2); else y = y0 + B2 * exp(-0.5 * ((x - xc2) / sig4) ^ 2);
where I change the line under the condition x<xc2 - pl. check and see if the paranthesis I inserted is in the right place etc.
Now, the issue of generating Y/X values given the X/Y values.
Once the fit has converged, you can just go to the Action->Results menu item in the NLSF tool and this page has the Find X/Y capability. You can enter in X or Y value and get the correspoding Y/X value displayed right in the tool.
Now, if you want to do the above from the script window, once the fit has converged, you can simply go to the script window and issue the command, for example: fit(2.3)= which will then display the Y value at X=2.3 The fit() function will always use the NLSF function and parameters as they exist at that time in Origin - so you need to first make sure the fit has converged before using this function.
There is currently no way from script to find X value given a Y value. For that you need to use the Action->Results page of NLSF that I mentioned above.
Easwar OriginLab
Edited by - easwar on 04/19/2005 5:47:12 PM |
flirt |
Posted - 04/19/2005 : 1:11:41 PM Right. So that means every time we want to get the value of x or y, the exact equation for x or y should be entered rights after entering the value of y or x?
I got another problem with the code builder. I write a function for a double asymmetric gaussian function, but can't get through. The error given shows no reason.
void _nlsfdsc2( // Fit Parameter(s): double A1, double xc1, double sig1, double sig2, double A2, double xc2, double sig3, double sig4, double y0, // Independent Variable(s): double x, // Dependent Variable(s): double& y) { // Beginning of editable part double B1 = A1 / (0.5 * (sig1 + sig2) * sqrt(2 * pi)); double B2 = A2 / (0.5 * (sig3 + sig4) * sqrt(2 * pi)); if( x < xc1 ) y = y0 + B1 * exp(-0.5 * ((x - xc1) / sig1) ^ 2); else if( x < xc2 ) y = y0 + B1 * exp(-0.5 * ((x - xc1) / sig2) ^ 2) + B2 * exp(-0.5 * x - xc2) / sig3) ^ 2); else y = y0 + B2 * exp(-0.5 * ((x - xc2) / sig4) ^ 2); // End of editable part } compiling... _nlfdsc2.fit C:\orginTemp\OriginC\NLSF\_nlfdsc2.fit(45) :Error, invalid term C:\orginTemp\OriginC\NLSF\_nlfdsc2.fit(45) :Error, general compile error C:\orginTemp\OriginC\NLSF\_nlfdsc2.fit(44) :Error, general compile error C:\orginTemp\OriginC\NLSF\_nlfdsc2.fit(44) :Error, general compile error C:\orginTemp\OriginC\NLSF\_nlfdsc2.fit(30) :Error, error(s) found in compiling function _nlsfdsc2
|
fzimnoch |
Posted - 04/19/2005 : 11:38:02 AM Hello Flirt:
I tried the tutorial and you don't get the right answer because you need to set x before typing the equation for dose response.
So steps 8 & 9 must proceed step 6.
The Tutorial will be corrected.
FRED |
|
|