is there any correction..?
    조회 수: 4 (최근 30일)
  
       이전 댓글 표시
    
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
답변 (1개)
  Walter Roberson
      
      
 2013년 2월 20일
        In your second bit of code, your S is a square diagonal matrix, not a diagonal matrix the same size as A.
참고 항목
카테고리
				Help Center 및 File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!