Ticket #7383: flatBG.m

File flatBG.m, 226 bytes (added by Mike Thomas, 7 years ago)
Line 
1function C = flatBG(x,y,sig,A)
2%Gaussian Cost function for flat background
3C = 0;
4A = A(1);
5for i = 1:length(x)
6    if sig(i) == 0
7        C = C + (y(i)-A)^2;
8    else
9        C = C + ((y(i)-A)/sig(i))^2;
10    end
11end