The Gram-Schmidt algorithm for unknown n?

14 visualizaciones (últimos 30 días)
Kai Whelan
Kai Whelan el 29 de Abr. de 2020
Comentada: ahmadreza hormozi el 18 de Mzo. de 2021
Hiya,
I’m trying to understand how to carry out the gram Schmidt algorithm when you have an unknown number of vectors n.
Any help would be appreciated.

Respuesta aceptada

David Hill
David Hill el 29 de Abr. de 2020
V is matrix input where vectors are column vectors. Output U is matrix with replacement vectors as column vectors.
n = size(V,1);
k = size(V,2);
U = zeros(n,k);
U(:,1) = V(:,1)/sqrt(V(:,1)'*V(:,1));
for i = 2:k
U(:,i) = V(:,i);
for j = 1:i-1
U(:,i) = U(:,i) - ( U(:,j)'*U(:,i) )/( U(:,j)'*U(:,j) )*U(:,j);
end
U(:,i) = U(:,i)/sqrt(U(:,i)'*U(:,i));
end
  4 comentarios
Kai Whelan
Kai Whelan el 29 de Abr. de 2020
All good now thanks.
ahmadreza hormozi
ahmadreza hormozi el 18 de Mzo. de 2021
nice job , thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by