source: MML/trunk/machine/SOLEIL/Booster/applications/getperte_pos_dim.m @ 4

Last change on this file since 4 was 4, checked in by zhangj, 10 years ago

Initial import--MML version from SOLEIL@2013

File size: 830 bytes
Line 
1% profil de perte
2
3function [estimates, model] = fitprofil(xdata, ydata)
4% Call fminsearch with a random starting point.
5start_point = [1 2]; % sig et zb
6model = @expfun;
7estimates = fminsearch(model, start_point);
8% expfun accepts curve parameters as inputs, and outputs sse,
9% the sum of squares error for A * exp(-lambda * xdata) - ydata,
10% and the FittedCurve. FMINSEARCH only needs sse, but we want to
11% plot the FittedCurve at the end.
12    function [sse, FittedCurve] = expfun(params)
13        sig = params(1);
14        zb  = params(2);
15        z0m =5;
16        z   =xdata
17        for z0=-z0m:1:z0m
18           gauss=exp(-0.5*((z-z0-zb)/sig).^2);
19           profil=profil + gauss;
20        end
21       
22        FittedCurve = profil;
23        ErrorVector = FittedCurve - ydata;
24        sse = sum(ErrorVector .^ 2);
25    end
26end
27
28
Note: See TracBrowser for help on using the repository browser.