www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/StepTheDefaultSampleRateConverterExample.m
%% Convert the Sample Rate of a Sinusoid % Create a multistage sample rate converter with default properties. The % converter converts from 192 kHz to 44.1 kHz in three stages. % Copyright 2015 The MathWorks, Inc. %% src = dsp.SampleRateConverter; %% % Use |src| to convert the sample rate of a noisy sinusoid. The sinusoid % has a frequency of 20 kHz and is sampled for 0.1 s. f = 20e3; FsIn = src.InputSampleRate; FsOut = src.OutputSampleRate; t1 = (0:1/FsIn:0.1-1/FsIn)'; sIn = sin(2*pi*f*t1) + randn(size(t1)); %% % Estimate the power spectral density of the input. hsa = dsp.SpectrumAnalyzer('SampleRate',FsIn); step(hsa,sIn) %% % Convert the sample rate of the signal. Estimate the power spectral % density of the output. sOut = step(src,sIn); hsb = dsp.SpectrumAnalyzer('SampleRate',FsOut); step(hsb,sOut)