MATLAB Curve fitting to diffusion equation(Matlab)

Click For Summary
The discussion focuses on fitting experimental diffusion results to the diffusion equation using Matlab to determine the Diffusion coefficient. The equation utilized is y=C*erfc(x/(2*sqrt(D*t))), with experimental values for x, y, and t provided, while C and D are to be evaluated. Users encountered an error indicating that the input for the error function must be real, suggesting that the D parameter may be turning negative during fitting. A proposed solution is to use the absolute value of D, although this might complicate the fitting process. The conversation emphasizes the need for real input arguments in the fitting procedure to achieve accurate results.
msumani
Messages
1
Reaction score
0
We have been trying to fit experimental diffusion results to the diffusion equation using Matlab to evaluate the Diffusion coefficient.
The equation we used:
y=C*erfc(x/(2*sqrt(D*t)))
Experimental values [x],[y] and t are given. C and D are to be evaluated from the curve fit.
We used cftool of Matlab.
We have a problem in getting the results. We get error message as:

"Error using ==> <a href="error:C:\Program Files\MATLAB\R2007b\toolbox\curvefit\curvefit\@fittype\feval.m,97,0">fittype.feval at 97</a>
Error in fittype expression ==> C.*erfc(x./(2.*sqrt(D.*300)))
? Error using ==> erfcore
Input must be real."

Can anyone help?
 
Physics news on Phys.org
It looks like the problem is that the error function requires real input arguments. Looking at your expression I would say the most likely problem is that the D parameter gets negative during the fitting, and as such maybe you could try to use abs(D) instead, although this could lead to the fitting algorithm having problems finding the right values.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 41 ·
2
Replies
41
Views
10K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K