demoiff.asv

来自「A fourier filter for time-series signals」· ASV 代码 · 共 55 行

ASV
55
字号
% Self-contained demonstration of Interactive Fourier Filter
% with sliders for interactive control. The Signal slider selects from 
% five different signals (you can change these in iffsignal.m). The
% Center slider controls the center frequency of the filter, the Width  
% slider controls the width, and the Shape slider controls the shape 
% of the pass band. If shape = 1, the filter is Gaussian; as shape 
% increases, the filter shape becomes more and more rectangular. 
% mode=0 for band-pass filter, linear plot; mode=1 for  band-pass filter,
% semilogx plot; mode=2 for band-reject (notch) filter, linear plot;
% mode=3 for band-reject (notch) filter, semilogx plot.
% In this version, the original and filtered signals are
% displayed in separate windows. To display the original 
% signal and filtered signal superimposed in the same window, 
% rename AlternativeRedrawFourierFilter.m to RedrawFourierFilter.m 
%  T. C. O'Haver (toh@umd.edu), version 1.4, October 29, 2006
clear
global x
global y
global ry
global center
global width
global shape
global mode
global signalstring
close

% Generate simulated signal
n=200;
x=[1:n];
signalstring='Sine wave with frequency = 1';
y=sin(2*pi.*x./n); % Simple sine wave with frequency = 1.

% Initial values of filter parameters
center=1;
width=28;
shape=2;
mode=0; % mode=0 for band-pass filter, mode=1 for band-reject (notch) filter

% Plot the signal and its power spectrum
ry=RedrawFourierFilter(x,y,center,width,shape,mode);
h=figure(1);
h2=gca;
  
% Maximum ranges of the sliders (change as needed)
MaxCenter=(length(x)/2)-1;
MaxWidth=length(x);
MaxShape=20;

% Draw the sliders
rtslid(h,@iffcenter,h2,1,'Scale',[0 MaxCenter],'Def',center,'Back',[0.9 0.9 0.9],'Label','Center','Position',[0.02 0.13 0.03 0.68]);
rtslid(h,@iffsignal,h2,0,'Scale',[1 5],'Def',1,'Back',[0.9 0.9 0.9],'Label','Signal','Position',[0.02 0.88 0.03 0.06]);
rtslid(h,@iffmode,h2,0,'Scale',[0 3],'Def',.1,'Back',[0.9 0.9 0.9],'Label','Mode','Position',[0.02 0.02 0.03 0.04]);
rtslid(h,@iffwidth,h2,0,'Scale',[1 MaxWidth],'Def',width,'Back',[0.9 0.9 0.9],'Label','Width','Position',[0.95 0.24 0.03 0.68]);
rtslid(h,@iffshape,h2,0,'Scale',[1 MaxShape],'Def',shape,'Back',[0.9 0.9 0.9],'Label','Shape','Position',[0.95 0.05 0.03 0.1]);

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?