image thumbnail

EXPO 2011 Signal Processing Workflow Demo Files

by

 

MATLAB EXPO 2011 Signal Processing Workflow Demo Files

filter_spec_dsp.m
%% fdesignIuWFNggtB^݌v
clear all, close all, clc

%% CӃO[vxtB^
Fad = fdesign.arbgrpdelay				% dl̐ݒ
set(Fad,'specification')				% ݌vdl̊mF
set(Fad,'specification','N,F,Gd'),Fad	% ݌vdl̐ݒ
set(Fad,'FilterOrder',20)				% ̐ݒ
set(Fad,'Frequencies',[0:0.1:1])		% gxNg
set(Fad,'GroupDelay', [ones(1,5) 50 ones(1,5)])	% xxNg
designmethods(Fad)						% ݌v@̊mF
Had = design(Fad,'iirlpnorm');			% ݌v@̑I
fvtool(Had,'grpdelay')					% ̉Ž

%% CӐUʑtB^
% Uƈʑ𕡑fxNgɂݒł
Famp = fdesign.arbmagnphase				% dl̐ݒ
set(Famp,'specification')				% ݌vdl̊mF
set(Famp,'specification','N,B,F,H')		% ݌vdl̐ݒ
set(Famp,'FilterOrder',30)				% ̐ݒ
set(Famp,'NBands',1)					% oh
set(Famp,'B1Frequencies', [0   0.1 0.2 0.4 0.5 0.6 0.9 1.0])	% gxNg
set(Famp,'B1FreqResponse',[0.8 0.8 0.7 0.3 0.3 1   1   0])	% UxNg
designmethods(Famp)						% ݌v@̊mF
Hamp = design(Famp,'firls');			% ݌v@̑I
fvtool(Hamp)					% ̉Ž

%% I[fBId݃tB^
% mCY⑛̂߂̋KiɏtB^݌v
Fau1 = fdesign.audioweighting			% dl̐ݒ
set(Fau1,'specification')				% ݌vdl̊mF
set(Fau1,'specification','WT')			% ݌vdl̐ݒ
set(Fau1,'WeightingType','ITUT041'),Fau1	% ̐ݒ
designmethods(Fau1)						% ݌v@̊mF
Hau1 = design(Fau1,'freqsamp');			% ݌v@̑I

Fau2 = fdesign.audioweighting				% dl̐ݒ
set(Fau2,'specification')				% ݌vdl̊mF
set(Fau2,'specification','WT,Class')		% ݌vdl̐ݒ
set(Fau2,'WeightingType','A')				% ̐ݒ
set(Fau2,'Class',1)				% ̐ݒ
designmethods(Fau2)						% ݌v@̊mF
Hau2 = design(Fau2,'ansis142');			% ݌v@̑I

fvtool(Hau1,Hau2)					% ̉Ž
legend('ITU-T 0.41 Weighting','A weighting')

%% C^[|[VtB^
l   = 15;   % Set the interpolation factor and the Nyquist band.
tw  = 0.05; % Specify the normalized transition width.
ast = 40;   % Set the minimum stopband attenuation in dB.
Fi  = fdesign.interpolator(l,'nyquist',l,tw,ast);
Hi1  = design(Fi,'kaiserwin');
Hi2 = design(Fi,'multistage'); % Design the multistage interpolator.
h0 = fvtool(Hi1,Hi2);
legend(h0,'Kaiser Window','Multistage')
cost(Hi1),cost(Hi2)

%% fV[VtB^
% TvOg𗎂Ƃ߂̊Ԉ
Fs = 96e3;Fp = 4e3; % Frequency band of interest.
m = 6;  % Decimation factor
Fdc = fdesign.decimator(m,'cic',1,Fp,60,Fs)
designmethods(Fdc)
Hdc = design(Fdc,'multisection');
h1 = fvtool(Hdc)
legend(h1,'CIC Decimation')

%% CIC⏞tB^
% CICtB^⏞
Fcc = fdesign.ciccomp(Hdc.differentialDelay,...
	Hdc.NumberOfSections,Fp,4.5e3,0.1,60,Fs/m)	% dl̐ݒ
designmethods(Fcc)						% ݌v@̊mF
Hcc = design(Fcc,'equiripple');		% ݌v@̑I
addfilter(h1,Hcc)					% ̉Ž
legend(h1,'CIC Decimation', 'CIC Compensator')

%% CICfV[VCIC⏞tB^JXP[hڑ
Hcas = cascade(Hdc,Hcc)
addfilter(h1,Hcas)
legend(h1,'CIC Decimation', 'CIC Compensator','Cascade')

%% Ri`jmb`уs[NtB^
Fcn  = fdesign.comb('notch','N,BW',8,0.02);
designmethods(Fcn)
Hcn = design(Fcn);

Fcp  = fdesign.comb('peak','N,BW',8,0.02);
designmethods(Fcp)
Hcp = design(Fcp);

h2 = fvtool(Hcn,Hcp)
legend(h2,'Notch','Peak')

%% Fractional DelaytB^
% x
Ff = fdesign.fracdelay(40/8000,'N',3);
designmethods(Ff)
Hf = design(Ff)
fvtool(Hf)

%% n[tohtB^
Fhb1 = fdesign.halfband('N,Ast',84, 80)
designmethods(Fhb1)
Hhb1 = design(Fhb1,'equiripple')

Fhb2 = fdesign.halfband('N,Ast',84, 80)
set(Fhb2,'Type','Highpass')
designmethods(Fhb2)
Hhb2 = design(Fhb2,'equiripple')

h3 = fvtool(Hhb1,Hhb2);
legend(h3,'Lowpass','Highpass')

%% tSinc[pX/nCpXtB^
Fisl = fdesign.isinclp('N,Fp,Fst',50,.4,.5);
designmethods(Fisl)
Hisl = design(Fisl,'SincFrequencyFactor',0.25,'SincPower',16);

Fish = fdesign.isinchp('N,Fst,Fp',50,.5,.6);
designmethods(Fish)
Hish = design(Fish,'SincFrequencyFactor',0.25,'SincPower',16);
h4 = fvtool(Hisl,Hish, 'MagnitudeDisplay', 'Magnitude');	% UjA\
legend(h4,'Inverse sinc Lowpass','Inverse sinc Highpass')

%% mb`/s[NtB^
Fn  = fdesign.notch('N,F0,Q,Ap',6,0.5,10,1);
designmethods(Fn)
Hn = design(Fn);

Fp  = fdesign.peak('N,F0,Q,Ap',6,0.5,10,1);
designmethods(Fp)
Hp = design(Fp);

fvtool(Hn,Hp)

%% iCLXgtB^
% V{Ԋ‚̖tB^݌v
Fny=fdesign.nyquist(4,'N,TW',24,0.2);
% Equiripple Nyquist 4th-band filter with
% nonnegative zero phase response
Hny=design(Fny,'equiripple','zerophase',true);
fvtool(Hny)

%% IN^[utB^
% IN^[utB^oN̐݌v
% I[fBIMł̉͂̂߂̃tB^݌v
BandsPerOctave = 2;
N = 6; F0 = 100;       % Center Frequency (Hz)
Fs = 48000;      % Sampling Frequency (Hz)
Foc = fdesign.octave(BandsPerOctave,'Class 0','N,F0',N,F0,Fs)
F0 = validfrequencies(Foc);
for i=1:length(F0),
	Foc.F0 = F0(i);
    Hoc(i) = design(Foc,'butter');
end
h5 = fvtool(Hoc,'FrequencyScale','log');
axis([0.01 24 -90 5])

%% pgbNCRCU
% I[fBIppgbNCRCU̐݌v
F0 = 0;    % Highpass Shelving Filter
Fc = 0.3;
Qa = 0.4; G0 = 8; N=2;
Fpe = fdesign.parameq('N,F0,Fc,Qa,G0',N,F0,Fc,Qa,G0);
Hpe1 = design(Fpe);

Fpe.Qa = 0.7071;
Hpe2 = design(Fpe);

Fpe.Qa = 2;
Hpe3 = design(Fpe);

Fpe.Qa = 8;
Hpe4 = design(Fpe);
fvtool(Hpe1,Hpe2,Hpe3,Hpe4)
legend('Q=0.4','Q=0.7071','Q=2','Q=8');

%% Tv[gRo[^
% ̃Tv[gϊstB^݌v
[L,M] = rat(48/44.1)
Fsr = fdesign.polysrc(L,M,'Fractional Delay','Np',3);
Hsr = design(Fsr,'lagrange')
fvtool(Hsr)

Fs = 44.1e3;	% Sample Rate
n = 0:1023;		% 9408 samples, 0.213 seconds long
x  = sin(2*pi*1e3/Fs*n);	% Sin Wave
y = filter(Hsr,x);

figure
stem(n(1:45)/Fs,x(1:45)),hold on
% Plot fractionally interpolated signal (48kHz) in red
stem((n(3:51)-2)/(Fs*L/M),y(3:51),'r','filled')
xlabel('Time (sec)');ylabel('Signal value')
legend('44.1 kHz sample rate','48 kHz sample rate'),hold off

Contact us