Fitting gaussian to a seriers of spectra

2 views (last 30 days)
Michele
Michele on 3 May 2012
Hi, i'm using this code
%%Read data and fitting
[m,n]=size(A);
k=1;
for i=1:(n-1)/2
wl=A(:,2*i-1);
abs=A(:,2*i);
yy=smooth(abs);
[gaussfit]=fit(wl, yy, 'gauss1');
figure(1)
plot(gaussfit)
legend('off')
hold on
[a,b]=max(abs);
index(k,1)=b;
maxima(k,1)=wl(b);
k=k+1;
end
figure(2) % plot(index,'o') % hold on plot(maxima,'o')
to fit the data in the worksheet A (are alternatively the x and the y of the spectra i'm analysing). Whit the first table i tried i worked fine but with the second one i gives this error:
??? Inf computed by model function.
Error in ==> fit at 443 errstr = handleerr( errid, errmsg, suppresserr );
I think the reason could be two: #1 In this new tables i have some negative values #2 Some curve are really "unfittable" by a gaussian (they are flat pretty much)
Considering i'm a matlab noob there is a way to solve this problem (that actually i do not even know what it is) Thanks mik

Answers (0)

Categories

Find more on Interpolation 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!