source: MML/trunk/machine/SOLEIL/StorageRing/insertions/IDStarter/idLeastSqLinFit.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: 846 bytes
Line 
1function resV = idLeastSqLinFit(M, V, arIndsBPMsToSkip)
2
3numBPMs = length(V);
4numBPMsToSkip = length(arIndsBPMsToSkip);
5actNumBPMs = numBPMs - numBPMsToSkip;
6if(numBPMsToSkip <= 0)
7    workM = M;
8    workV = V;
9else
10    workM = zeros(actNumBPMs, 2);
11    workV = zeros(actNumBPMs, 1);
12    countBPM = 1;
13    for i = 1:numBPMs
14        skipThisBPM = 0;
15        for j = 1:numBPMsToSkip
16            if(i == arIndsBPMsToSkip(j))
17                skipThisBPM = 1;
18                break;
19                end
20        end
21        if(skipThisBPM ~= 0)
22            continue;
23        end
24       
25        workV(countBPM) = V(i);
26        workM(countBPM, 1) = M(i, 1);
27        workM(countBPM, 2) = M(i, 2);
28        countBPM = countBPM + 1;
29    end
30end
31
32transpM = workM';
33squareM = transpM*workM;
34invSquareM = inv(squareM);
35finM = invSquareM*transpM;
36resV = finM*workV;
Note: See TracBrowser for help on using the repository browser.