Line | |
---|
1 | function [Mapprox,misscols] = approx_matrix(M,INC,NULLSPACE,r,numcols)
|
---|
2 | Mapprox = [];
|
---|
3 | misscols = [];
|
---|
4 |
|
---|
5 | %[A,S,U] = svd(NULLSPACE',0);
|
---|
6 | [U,S,V] = svd(NULLSPACE);
|
---|
7 |
|
---|
8 | Unumcols = size(U,2);
|
---|
9 | %SINGULARVALUES = diag(S)'
|
---|
10 | if svd_suff_data(S,r)
|
---|
11 | RSPACE = U(:,Unumcols+1-r:Unumcols);
|
---|
12 | % RSPACE has r columns, which span the r-D space that gives the best linear
|
---|
13 | % surface to approximate M.
|
---|
14 | for i = 1:numcols
|
---|
15 | INCcol = INC(:,i);
|
---|
16 | Mcol = M(:,i).*INCcol;
|
---|
17 | INCmat = repeat(INCcol, r);
|
---|
18 | RSPACEcols = RSPACE.*INCmat;
|
---|
19 | % this is just RSPACE with all the rows missing that are also missing in Mcol.
|
---|
20 | if rank(RSPACEcols) == r
|
---|
21 | Mapprox = [Mapprox, RSPACE*(RSPACEcols\Mcol)];
|
---|
22 | else
|
---|
23 | misscols = [misscols, i];
|
---|
24 | end
|
---|
25 | end
|
---|
26 | else
|
---|
27 | Mapprox = -2;
|
---|
28 | end
|
---|
29 | if isempty(Mapprox) Mapprox = -2; end |
---|
Note: See
TracBrowser
for help on using the repository browser.