Line | |
---|
1 | function [E, stable] = extend_matrix(M,INC,subM, rows, nonrows, r)
|
---|
2 | % rows indicates which rows of M and INC were used to find a solution.
|
---|
3 | % subM is a fit to just these rows. nonrows indicate rows of M
|
---|
4 | % that still need to be fit.
|
---|
5 | E(rows,:) = subM;
|
---|
6 | stable = 1;
|
---|
7 |
|
---|
8 | if ~isempty(nonrows)
|
---|
9 |
|
---|
10 | [u,s,v] = svd(subM);
|
---|
11 | vp = v';
|
---|
12 | basis = vp(1:r,:);
|
---|
13 | for i = nonrows
|
---|
14 | INCrow = INC(i,:);
|
---|
15 | Mrow = M(i,:).*INCrow;
|
---|
16 | INCmat = repeat(INCrow',r)';
|
---|
17 | basisrows = basis.*INCmat;
|
---|
18 | if rank(basisrows) ~= r
|
---|
19 | stable = 0
|
---|
20 |
|
---|
21 | % putting zeros in for the elements that cannot be determined.
|
---|
22 | % to avoid dividing by a matrix that is not full rank.
|
---|
23 | E(i,:) = Mrow;
|
---|
24 |
|
---|
25 | %instead of zeros, choose a random value between -1 and 1 for each
|
---|
26 | %unfindable missing point.
|
---|
27 | missingpoints = find(INCrow == 0);
|
---|
28 | E(i,missingpoints) = rand(1,length(missingpoints)).*2 - 1;
|
---|
29 | else
|
---|
30 | E(i,:) = (Mrow/basisrows)*basis;
|
---|
31 | end
|
---|
32 | end
|
---|
33 |
|
---|
34 | end
|
---|
Note: See
TracBrowser
for help on using the repository browser.