Why does the Gaussian fit function become highly inaccurate after 24 iterations in a for loop?
2 views (last 30 days)
Show older comments
I am attempting to fit 24 spectra corresponding with 24 files in a directory with MatLab's Gaussian fit function, 'gauss6'. These spectra are processed in a for loop that repeats for each file in the directory. The outputs of this loop are the optimized peak locations, intensities, etc. However, when MatLab attempts to perform the fit function for the 24th spectrum, the final peak's position (sixth) is completely incorrect, while the other five peaks are just as correct as the previous 23 spectra. This doesn't occur for directories of 23 files or less, but always happens to the final peak of the final spectrum if the number of spectra being fit is greater than 24.
Things I have tried:
- Given 25 spectra, the last peak of the 25th is incorrect. It's always the final peak of the last file/spectrum if the files are greater than 24.
- Isolating the 24th spectrum by itself yields a correct fitting.
- It seems like the R^2 gets worse slowly as the number of spectra being fit increases.
3 Comments
Answers (0)
See Also
Categories
Find more on Parametric Spectral Estimation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!