1d Diffusion (for a complete newbe)
Ältere Kommentare anzeigen
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
Antworten (1)
Geoff Hayes
am 22 Nov. 2015
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 Kommentare
Stefan Schwab
am 22 Nov. 2015
Bearbeitet: Geoff Hayes
am 23 Nov. 2015
Geoff Hayes
am 23 Nov. 2015
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
am 23 Nov. 2015
Geoff Hayes
am 23 Nov. 2015
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
am 23 Nov. 2015
Kategorien
Mehr zu Get Started with Curve Fitting Toolbox finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!