📄 undelay.m
字号:
function sig = undelay(delaysig,d,m,step,method,recon);%undelay - regenerate the undelayed signal%% sig = undelay(delaysig,d,m,step,method,recon);%% recon='avg' average over possible values % recon='quad' average over (quadratic) weighted possible values %% 01.08.03 - initial version% 01.11.04 - using undelay architecture% Peter Grubererror(nargchk(2,6,nargin)) % check no. of input argsif (nargin<4) step=1; endif (nargin<5) method='multidim'; endif (nargin<6) recon='avg'; endswitch method case 'multidim' flip='flip'; otherwise flip='no';end% fast version for 1-dim signalsif (length(d)==2) if ((d(1)==1)||(d(2)==1)) q=m^2+1-[-m:m].^2; q=(2*m+1)*q/sum(q); for i=-m:m j=i+m+1; b=round(i*step); switch recon case 'avg' delaysig(j,:)=circshift(delaysig(j,:)',b)'; case 'quad' delaysig(j,:)=q(j)*circshift(delaysig(j,:)',b)'; end end sig=sum(delaysig,1)/size(delaysig,1); switch flip case 'flip' l=length(sig); c=ceil(l/2)+1; sig=sum([sig(1:c);[sig(1),sig(l:-1:c)]],1)/2; end return endendpot=0;switch recon case 'avg'; pot=0; case 'quad'; pot=2; otherwise; pot=0;endsig=undelay_multidim(delaysig,d,m,step,pot,flip);returnfunction sig = undelay_multidim(delaysig,d,lag,step,pot,preprocess);%delay - compute delayed/undelayed signal with lag and step%% sig = undelay_multidim(delaysig,d,lag,step,pot,preprocess);%% lag - distance to consider% step - step%% 1.10.03 - initial version% 1.10.04 - rewrite% Peter Grubererror(nargchk(3,6,nargin)) % check no. of input argsif (nargin<4) step=1; endif (nargin<5) pot=0; endif (nargin<6) preprocess='no'; endswitch preprocess case 'no' ndims=d; case 'flip' ndims=(2*d)-2;end% find offsets and weightsmdist=ceil(lag)+2;tcoord=ones(1,length(d))*(-mdist);linoffs=[];weights=[];while (sum(tcoord)<(length(d)*mdist)) td=sqrt(sum(tcoord.^2)); if (td<=lag) linoffs=[linoffs tcoord']; weights=[weights (td^pot)]; end tcoord(1)=tcoord(1)+1; for i=1:length(d)-1 if (tcoord(i)>mdist) tcoord(i+1)=tcoord(i+1)+1; tcoord(i)=-mdist; end endend % delaydimensionlo=size(linoffs,2);% trivial caseif (lo==0) delaysig=[]; returnend% length of delayed cordinatesnd=prod(ndims);ld=length(ndims);if ((lo~=size(delaysig,1))||(nd~=size(delaysig,2))) error('wrong input (does not match dalayed data)')end% normalise weightweights=weights-(min(weights)-1);weights=weights/sum(weights);% shift the dimensions in ns and recontruct sigsig=zeros(ndims);for j=1:lo tns=reshape(delaysig(j,:),ndims); tns=circshift(tns,linoffs(:,j)); sig=sig+weights(j)*tns;endswitch preprocess case 'flip' for i=1:ld p=prod(d(1:i-1)); q=ndims(i); s=d(i); r=prod(ndims(i+1:ld)); t=reshape(sig,[p,q,r]); sig=(t(:,[1:s],:)+t(:,[1,[q:-1:s]],:))/2; end sig=reshape(sig,d);endreturn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -