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 | |
---|
1 | function resV = idLeastSqLinFit(M, V, arIndsBPMsToSkip) |
---|
2 | |
---|
3 | numBPMs = length(V); |
---|
4 | numBPMsToSkip = length(arIndsBPMsToSkip); |
---|
5 | actNumBPMs = numBPMs - numBPMsToSkip; |
---|
6 | if(numBPMsToSkip <= 0) |
---|
7 | workM = M; |
---|
8 | workV = V; |
---|
9 | else |
---|
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 |
---|
30 | end |
---|
31 | |
---|
32 | transpM = workM'; |
---|
33 | squareM = transpM*workM; |
---|
34 | invSquareM = inv(squareM); |
---|
35 | finM = invSquareM*transpM; |
---|
36 | resV = finM*workV; |
---|
Note: See
TracBrowser
for help on using the repository browser.