22 lines
353 B
Mathematica
22 lines
353 B
Mathematica
|
% Vraag 4
|
||
|
clear all
|
||
|
t=(-0.2:0.1:3)'
|
||
|
B=[ones(size(t)) cos(pi*t) cos(pi/2*t).^2 sin(pi*t) sin(pi/2*t).^2]
|
||
|
b=t.^2
|
||
|
|
||
|
|
||
|
[U, S, V] = svd(B)
|
||
|
|
||
|
diag(S)
|
||
|
r = 3
|
||
|
|
||
|
U1 = U(:,1:r) % orhonormale basis voor Col B
|
||
|
U2 = U(:,r+1:end) % Nul B transpose; staat loodrecht op col B
|
||
|
pCol = U1*U1'*b
|
||
|
pNul = U2*U2'*b
|
||
|
|
||
|
% som v/d beide projecties moet nul zijn.
|
||
|
|
||
|
b- pCol - pNul
|
||
|
|