필터 지우기
필터 지우기

Least Square Solution Using Matlab.

조회 수: 1 (최근 30일)
Pranjal Pathak
Pranjal Pathak 2012년 2월 15일
The following is a matlab coding for least square solution. I have got this from a book and need to work on this. Can anyone please help me in running the program:
%This function reconstructs wave front from the x-slope matrix Sx and the y-slope matrix Sy. %Both Sx and Sy must be square matrices with the size. %ds is the distance between the neighbouring points.
function W=Zonal Reconstruction(Sx, Sy, ds); [n, n]=[reshape(Sx', 1, n*n) reshape(Sy', 1, n*n)]'; E=getE(n); [U, D, V]=svd(E, 0); D=pinv(D); C=getC(n); W=V*D*U'*C*S; W=reshape(W', n, n)./ds;
%This function obtains the matrix E for the zonal reconstruction function E=getE(n); E=zeros(2*n*(n-1), n*n); for i=1:n for j=1:(n-1) E((i-1)*(n-1)+j, (i-1)*n+j)=-1; E((i-1)*(n-1)+j, (i-1)*n+j+1)=1; E((n+i-1)*(n-1)+j, i+(j-1)*n)=-1; E((n+i-1)*(n-1)+j, i+j*n)=1; end end
%This function obtains the matrix C for zonal reconstruction function C=getC(n); C=zeros(2*n*(n-1), 2*n*n); for i=1:n for j=1:(n-1) C((i-1)*(n-1)+j, (i-1)*n+j)=0.5; C((i-1)*(n-1)+j, (i-1)*n+j+1)=0.5; C((n+i-1)*(n-1)+j, n*(n+j-1)+i)=0.5; C((n+i-1)*(n-1)+j, n*(n+j)+i)=0.5; end end ********** Where X=-1:63:+1,Y=-1:2/63:+1,Sx=6.928.*X,Sy=-6.928.*Y, n=64. Anything needed,just put according to your convenience. Actually, I need to know how to call this function. Thanking You!

답변 (1개)

Luis José Moreno Garrido
Luis José Moreno Garrido 2012년 3월 5일
I am trying to run as well.
Sx and Sy have to be squared matrix, and you are defining them as vectors. In any case, n = 64 is a huge number. Try with smaller ones.

카테고리

Help CenterFile Exchange에서 Genomics and Next Generation Sequencing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by