The Gram-Schmidt algorithm for unknown n?

15 ビュー (過去 30 日間)
Kai Whelan
Kai Whelan 2020 年 4 月 29 日
コメント済み: ahmadreza hormozi 2021 年 3 月 18 日
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.

採用された回答

David Hill
David Hill 2020 年 4 月 29 日
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 件のコメント
Kai Whelan
Kai Whelan 2020 年 4 月 29 日
All good now thanks.
ahmadreza hormozi
ahmadreza hormozi 2021 年 3 月 18 日
nice job , thanks

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by