Last change
on this file since 4 was 2, checked in by Rick van der Zwet, 15 years ago |
Initial import of data of old repository ('data') worth keeping (e.g. tracking
means of URL access statistics)
|
File size:
461 bytes
|
Rev | Line | |
---|
[2] | 1 | function Ak = approx(A, k)
|
---|
| 2 | % given matrix A and number k of top eigenvalues
|
---|
| 3 | % an approximation Ak is calculated via SVD
|
---|
| 4 | % k < m,n
|
---|
| 5 | [m, n] = size(A);
|
---|
| 6 | lo = m;
|
---|
| 7 | if ( n < m )
|
---|
| 8 | lo = n;
|
---|
| 9 | end
|
---|
| 10 | if ( lo < k )
|
---|
| 11 | k = lo;
|
---|
| 12 | end
|
---|
| 13 | [U, S, V] = svd(A);
|
---|
| 14 | svk = svds(A, k);
|
---|
| 15 | uk = U(:,[1:k]);
|
---|
| 16 | vk = V(:,[1:k]);
|
---|
| 17 | Ak = uk * diag(svk) * vk';
|
---|
| 18 | % plaatje is niet wenslijk in een functie, laten we erbuiten
|
---|
| 19 | % weergeven
|
---|
| 20 | % image(Ak);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.