Using lsqcurvefit with a function that contains a for loop
이전 댓글 표시
I want to fit Fick's Law for diffusion in a sphere using lsqcurvefit to experimental data.
The equation is an infinite series of the form
y = 1- sum((A/n^2 * exp(-B*n^2*t - t0))
I would like to create a function which sums the first 100 n terms using a for loop and then use lsqcurvefit to adjust parameter B to fit the experimental mass versus time data.
I know how to use lsqcurvefit, I just want to know how to fit this equation without adding the first 100 etc terms manually in the function file.
Thanks for your help,
Jon
답변 (1개)
No idea why you think you need a for loop. The SUM command will work just fine,
n=1:100;
y = 1- sum((A./n.^2 .* exp(-B*n.^2*t - t0));
카테고리
도움말 센터 및 File Exchange에서 Nearest Neighbors에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!