is there any correction..?

I am doing Singular value decomposition using this.
Xi = [1 2;3 4]; Yi = [1 2;3 4]; Zi = [1 2;3 4];
A=[Xi,Yi,Zi,ones(length(Xi),1)];
[U S V] = svd(A)
Now, i want to do the same without function. so, i written little as below.
Xi = [1 2;3 4]; Yi = [1 2;3 4]; Zi = [1 2;3 4];
A=[Xi,Yi,Zi,ones(length(Xi),1)];
f = eig(A'*A);
for l = 1:length(f);
p(l) = sqrt(f(l));
end
S = diag(p);
[U,D] = eig(A*A');
[V,D] = eig(A'*A);
V = V';
U
S
But in answer i am getting only some of its elements same in matrix. And remaining are different. So, please suggest any modification if there or solution..?

回答 (1 件)

Walter Roberson
Walter Roberson 2013 年 2 月 20 日

0 投票

In your second bit of code, your S is a square diagonal matrix, not a diagonal matrix the same size as A.

1 件のコメント

Lalit Patil
Lalit Patil 2013 年 2 月 20 日
編集済み: Lalit Patil 2013 年 2 月 21 日
Then what change to do in S.?
And before S i want to solve problem of U and V.
What change to do in them.?

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

カテゴリ

ヘルプ センター および File ExchangeCreating and Concatenating Matrices についてさらに検索

質問済み:

2013 年 2 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by