Skip to content

Instantly share code, notes, and snippets.

@mrgloom
Created November 13, 2014 09:43
Show Gist options
  • Save mrgloom/3943410759f04265f7cb to your computer and use it in GitHub Desktop.
Save mrgloom/3943410759f04265f7cb to your computer and use it in GitHub Desktop.
Matlab SVD projection
>> a = [1 2 3; 2 5 7; 3 7 9]
a =
1 2 3
2 5 7
3 7 9
>> [U S V] = svd(a)
U =
-0.2459 -0.3944 -0.8855
-0.5810 -0.6712 0.4603
-0.7758 0.6277 -0.0641
S =
15.1931 0 0
0 0.3707 0
0 0 0.1776
V =
-0.2459 0.3944 -0.8855
-0.5810 0.6712 0.4603
-0.7758 -0.6277 -0.0641
>> x = [3 4 5]
x =
3 4 5
>> Ur = U(:, 1:2)
Ur =
-0.2459 -0.3944
-0.5810 -0.6712
-0.7758 0.6277
>> xr = x*Ur
xr =
-6.9410 -0.7296
>> xn = xr*Ur'
xn =
1.9943 4.5228 4.9272
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment