Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

is there any correction..?

Asked by Lalit Patil

Lalit Patil (view profile)

on 18 Feb 2013

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..?

0 Comments

Lalit Patil

Lalit Patil (view profile)

Products

No products are associated with this question.

1 Answer

Answer by Walter Roberson

Walter Roberson (view profile)

on 20 Feb 2013

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

1 Comment

Lalit Patil

Lalit Patil (view profile)

on 20 Feb 2013

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.?

Walter Roberson

Walter Roberson (view profile)

Contact us