分享

matlab 重采样---Resampling

 笨笨强 2010-03-19
Resampling
      The toolbox provides a number of functions that resample a signal at a higher or lower rate.

Operation                                                     Function
Apply FIR filter with resampling                     upfirdn
Cubic spline interpolation                              spline
Decimation                                                    decimate
Interpolation                                                   interp
Other 1-D interpolation                                  interp1
Resample at new rate                                   resample

      The resample function changes the sampling rate for a sequence to any rate that is a ratio of two integers. The basic syntax for resample is
                         y = resample(x,p,q)
where the function resamples the sequence x at p/q times the original sampling rate. The length of the result y is p/q times the length of x.
      One resampling application is the conversion of digitized audio signals from one sampling rate to another, such as from 48 kHz (the digital audio tape standard) to 44.1 kHz (the compact disc standard).
      The example file contains a length 4001 vector of speech sampled at 7418 Hz:
          clear
          load mtlb
          whos
Name        Size        Bytes        Class
  Fs           1x1          8        double array
  mtlb      4001x1      32008        double array
Grand total is 4002 elements using 32016 bytes
Fs
Fs =
        7418

       To play this speech signal on a workstation that can only play sound at 8192 Hz, use the rat function to find integers p and q that yield the correct resampling factor:
[p,q] = rat(8192/Fs,0.0001)
p =
   127
q =
   115

       Since p/q*Fs = 8192.05 Hz, the tolerance of 0.0001 is acceptable; to resample the signal at very close to 8192 Hz:
               y = resample(mtlb,p,q);
      resample applies a lowpass filter to the input sequence to prevent aliasing during resampling. It designs this filter using the firls function with a Kaiser window. The syntax
                   resample(x,p,q,l,beta)
controls the filter's length and the beta parameter of the Kaiser window. Alternatively, use the function intfilt to design an interpolation filter b and use it with
                   resample(x,p,q,b)
       The decimate and interp functions do the same thing as resample with p = 1 and q = 1, respectively. These functions provide different anti-alias filtering options, and they incur a slight signal delay due to filtering. The interp function is significantly less efficient than the resample function with q = 1.
      The toolbox also contains a function, upfirdn, that applies an FIR filter to an input sequence and outputs the filtered sequence at a sample rate different than its original. See Multirate Filter Bank Implementation.
      The standard MATLAB environment contains a function, spline, that works with irregularly spaced data. The MATLAB function interp1 performs interpolation, or table lookup, using various methods including linear and cubic interpolation.  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多