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!