Curve fitting to diffusion equation(Matlab)

Click For Summary
SUMMARY

The discussion focuses on fitting experimental diffusion results to the diffusion equation using Matlab's cftool to evaluate the Diffusion coefficient (D). The equation employed is y=C*erfc(x/(2*sqrt(D*t))), where C and D are the parameters to be determined. Users encountered an error indicating that the input must be real, likely due to negative values for the D parameter during fitting. A suggested solution is to use abs(D) to avoid negative inputs, although this may complicate the fitting process.

PREREQUISITES
  • Understanding of the diffusion equation and its parameters
  • Familiarity with Matlab's cftool for curve fitting
  • Knowledge of the error function (erfc) and its requirements
  • Basic experience with parameter estimation techniques
NEXT STEPS
  • Explore advanced options in Matlab's cftool for parameter constraints
  • Research methods for ensuring real-valued inputs in curve fitting
  • Learn about alternative fitting algorithms that handle negative parameters
  • Investigate the implications of using absolute values in parameter fitting
USEFUL FOR

Researchers and engineers working with diffusion processes, Matlab users involved in curve fitting, and anyone seeking to optimize parameter estimation in experimental data analysis.

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
4K
  • · Replies 6 ·
Replies
6
Views
6K
  • · 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