Least Square Solution Using Matlab.
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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!
0 comentarios
Respuestas (1)
Luis José Moreno Garrido
el 5 de Mzo. de 2012
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.
0 comentarios
Ver también
Categorías
Más información sobre Genomics and Next Generation Sequencing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!