[ps,rb]=powspec(ad,ft) Make a 1D power spectrum of a 2D array Try to make the bins the same width as ft ones and the centers run from just below 0 to just above maxr Twin function is realize to go the other way.
0001 function [ps,rb]=powspec(ad,ft) 0002 % [ps,rb]=powspec(ad,ft) 0003 % 0004 % Make a 1D power spectrum of a 2D array 0005 % 0006 % Try to make the bins the same width as ft ones and 0007 % the centers run from just below 0 to just above maxr 0008 % 0009 % Twin function is realize to go the other way. 0010 0011 m=max(ad.u_r(:)); 0012 top=m+ad.del_u/2; 0013 bot=-ad.del_u/2; 0014 span=top-bot; 0015 nbin=round(span/ad.del_u); 0016 0017 % Allow for taking the powspec of a stack of images 0018 u_r=repmat(ad.u_r,[1,1,size(ft,3)]); 0019 0020 % Remember abs(x).^2=x.*conj(x)=real(x).^2+imag(x).^2 0021 % Second is fastest 0022 [rb,ps]=hprof(u_r,ft.*conj(ft),nbin,bot,top); 0023 0024 % Kludge to make the first and last bin centers span 0025 % 0 and maxr 0026 rb(1)=-ad.del_u/1e3; 0027 rb(end)=m+ad.del_u/1e3; 0028 0029 return