function [UR,DS]=extract_eigenfunctions(U,V,OBS,DEPTH,l,r,R); % MATLAB HELP: % % function [UR,DS]=extract_eigenfunctions(U,V,OBS,DEPTH,l,r,R); % % inputs: % U, radial eigenfunctions % V, horizontal eigenfunctions % OBS, radial grid point that the observations are made ad % DEPTH, radial grid point where the source is located % l, angular degrees % r, grid in fractional radius % R, solar radius % outputs: % UR, radial displacement eigenfunctions at the observation % radius % DS, divergence of the displacement eigenfunctions at the source % depth % % % aaron birch, may 21, 2002 % allocate space for the divergence [N,M]=size(U); D=zeros(size(U)); % loop over the modes, computing the divergence for (i=1:N) D(i,:)=gradient(U(i,:),R*r)+(r*R).^(-1).*(2*U(i,:)-sqrt(l(i)*(l(i)+1))*V(i,:)); end; % % extract what we need % UR=U(:,OBS); DS=D(:,DEPTH);