Using lsqcurvefit with a function that contains a for loop
Ältere Kommentare anzeigen
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
Antworten (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));
Kategorien
Mehr zu Nearest Neighbors finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!