1d Diffusion (for a complete newbe)
이전 댓글 표시
Hello everyone, I am very sorry if this question is stupid but I am totally new to matlab and want to use the program to fit diffusion data with an error function. From my experiences I get values like that: x ... depth in cm y ... concentration in [atoms/cm³) What I have done so far was to import the data to Matlab by using the import data button. I have now the x values as doubles and the y values as doubles in the program. Now I tried to fit the values with the following formula:
y=(C-B)*erfc(X/sqrt(4*D*t))+B
C and D are unknown, B and t are constants (which I entered by number) Now I was trying to fit the data with the following expression:
....................
ft=fittype('(C-3,21694e18)*erfc(x/sqrt(4*D*225900))+3,21694e18', 'independent', 'x', 'dependent', 'y' );
fitresult=fit(x,y,ft);
plot(fitresult,x,y)
...................
This is all I wrote into the program, so probably I missed something very basic. Nevertheless I get an error message:
................
Error in Diffusionsfitting (line 1)
ft=fittype('(C-3,21694e18)*erfc(x/sqrt(4*D*225900))+3,21694e18', 'independent', 'x', 'dependent', 'y' );
Caused by:
Error using fittype/evaluate (line 102)
Error in fittype expression ==> (C-3,21694e18).*erfc(x./sqrt(4.*D.*225900))+3,21694e18
??? Error: Expression or statement is incorrect--possibly unbalanced (, {, or [.
...................
Can you probably tell me, what I am doing wrong? I know, I should spend more time on matlab since I am missing all the basics. But as I am not used to programming and with limited time during my Ph.D. it's gonna take very long and I would really need the results for my research. Thank you very much for you're help. BR, Stefan
답변 (1개)
Geoff Hayes
2015년 11월 22일
Stefan - I don't have the Curve Fitting Toolbox so I can't tell with certainty what may be the problem. But looking at expression to fittype
'(C-3,21694e18)*erfc(x/sqrt(4*D*225900))+3,21694e18'
you have two commas rather than periods for two of the numbers. Try replacing your expression with
'(C-3.21694e18)*erfc(x/sqrt(4*D*225900))+3.21694e18'
댓글 수: 5
Stefan Schwab
2015년 11월 22일
편집: Geoff Hayes
2015년 11월 23일
Geoff Hayes
2015년 11월 23일
It could be that your values are too high, but without knowing where or how you arrived at these values or what C or D etc. are, it will be difficult to comment on the behaviour you are observing.
Stefan Schwab
2015년 11월 23일
Geoff Hayes
2015년 11월 23일
Stefan - please attach your data as a file rather than copying and pasting it into a comment. Also, describe how you use this data within your code as it may not be clear to everyone what each value represents.
Stefan Schwab
2015년 11월 23일
카테고리
도움말 센터 및 File Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!