📄 examp_gabmul.m
字号:
%EXAMP_GABMUL Time-frequency localization by a Gabor multiplier%% This script creates several different time-frequency symbols% and demonstrate their effect on a random, real input signal.%%%% This figure shows the symbol (top plot, only the positive frequencies are displayed),% the input random signal (bottom) and the output signal (middle).% This program is free software: you can redistribute it and/or modify% it under the terms of the GNU General Public License as published by% the Free Software Foundation, either version 3 of the License, or% (at your option) any later version.% % This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.% % You should have received a copy of the GNU General Public License% along with this program. If not, see <http://www.gnu.org/licenses/>.disp('Type "help examp_gabmul" to see a description of how this example works.');% Setup some suitable parameters for the Gabor systemL=480;a=20;M=24;b=L/M;N=L/a;% Plotting initializationst_axis = (0:(M-1))*a;f_max = floor(N/2)-1;f_range = 1:(f_max+1);f_axis = f_range*b;xlabel_angle = 7;ylabel_angle = -11;% Create a tight window, so it can be used for both analysis and% synthesis.g=cantight(a,M,L);% Create the random signal.f=randn(L,1);% ------- sharp cutoff operator ---------% This cuts out a circle in the TF-plane. symbol1=zeros(M,N);for m=0:M-1 for n=0:N-1 if (m-M/2)^2+(n-N/2)^2 <(M/4)^2 symbol1(m+1,n+1)=1; end; end;end;% The symbol as defined by the above loops is centered such% that it keeps the high frequencys. To obtain the low ones, we% move the symbol along the first dimension:symbol1=fftshift(symbol1,1);% Do the actual filteringff1=gabmul(f,symbol1,g,a);% plottingfigure(1);if isoctave subplot(3,1,1); mesh(t_axis,f_axis,symbol1(f_range,:)); xlabel('Time'); ylabel('Frequency'); subplot(3,1,2); plot(real(ff1),';;'); subplot(3,1,3); plot(f,';;');else subplot(3,1,1); mesh(t_axis,f_axis,symbol1(f_range,:)); xlabel('Time','rotation',xlabel_angle); ylabel('Frequency','rotation',ylabel_angle);% axis tight; subplot(3,1,2); plot(real(ff1));% axis tight; subplot(3,1,3); plot(f);% axis tight;end;% ---- Tensor product symbol, keep low frequencies.t1=pgauss(M);t2=pgauss(N);symbol2=fftshift(t1*t2',2);% Do the actual filteringff2=gabmul(f,symbol2,g,a);figure(2);if isoctave subplot(3,1,1); mesh(t_axis,f_axis,symbol2(f_range,:)); xlabel('Time'); ylabel('Frequency'); subplot(3,1,2); plot(real(ff2),';;'); subplot(3,1,3); plot(f,';;'); else subplot(3,1,1); mesh(t_axis,f_axis,symbol2(f_range,:));% axis tight; xlabel('Time','rotation',xlabel_angle); ylabel('Frequency','rotation',ylabel_angle); subplot(3,1,2); plot(real(ff2));% axis tight; subplot(3,1,3); plot(f);% axis tight;end;% ----- Tensor product symbol, keeps middle frequencies.t1=circshift(pgauss(M,.5),round(M/4))+circshift(pgauss(M,.5),round(3*M/4));t2=pgauss(N);symbol3=fftshift(t1*t2',2);% Do the actual filteringff3=gabmul(f,symbol3,g,a);figure(3);if isoctave subplot(3,1,1); mesh(t_axis,f_axis,symbol3(f_range,:)); xlabel('Time'); ylabel('Frequency'); subplot(3,1,2); plot(real(ff3),';;'); subplot(3,1,3); plot(f,';;'); else subplot(3,1,1); mesh(t_axis,f_axis,symbol3(f_range,:)); xlabel('Time','rotation',xlabel_angle); ylabel('Frequency','rotation',ylabel_angle); subplot(3,1,2); plot(real(ff1));% axis tight; subplot(3,1,3); plot(f);% axis tight;end;% % ---- Tensor product symbol, keep low frequencies.% t1=pgauss(M);% t2=pgauss(N);% % symbol2=fftshift(t1*t2',2);% % % Do the actual filtering% ff2=gabmul(f,symbol2,g,a);% % % figure(2);% subplot(3,1,1);% mesh(symbol2);% % if isoctave% subplot(3,1,2);% plot(real(ff2),';;');% % subplot(3,1,3);% plot(f,';;');% else% subplot(3,1,2);% plot(real(ff2));% % subplot(3,1,3);% plot(f);% end;% % % ----- Tensor product symbol, keeps middle frequencies.% t1=circshift(pgauss(M,.5),round(M/4))+circshift(pgauss(M,.5),round(3*M/4));% t2=pgauss(N);% % symbol3=fftshift(t1*t2',2);% % % Do the actual filtering% ff3=gabmul(f,symbol3,g,a);% % % figure(3);% subplot(3,1,1);% mesh(symbol3);% % if isoctave% subplot(3,1,2);% plot(real(ff3),';;');% % subplot(3,1,3);% plot(f,';;');% else% subplot(3,1,2);% plot(real(ff3));% % subplot(3,1,3);% plot(f);% end;%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -