S-Transform_example.zip

  • 哼哈哈哈哈
    了解作者
  • matlab
    开发工具
  • 5KB
    文件大小
  • zip
    文件格式
  • 0
    收藏次数
  • 1 积分
    下载积分
  • 0
    下载次数
  • 2021-03-18 17:22
    上传日期
一个用S变换对谐波分解变换的电能扰动例子。
S-Transform_example.zip
  • S-Transform_example
  • st.m
    13.7KB
  • example1.m
    921B
内容介绍
function [st,t,f] = st(timeseries,minfreq,maxfreq,samplingrate,freqsamplingrate) % Returns the Stockwell Transform of the timeseries. % Code by Robert Glenn Stockwell. % DO NOT DISTRIBUTE % BETA TEST ONLY % Reference is "Localization of the Complex Spectrum: The S Transform" % from IEEE Transactions on Signal Processing, vol. 44., number 4, April 1996, pages 998-1001. % %-------Inputs Needed------------------------------------------------ % % *****All frequencies in (cycles/(time unit))!****** % "timeseries" - vector of data to be transformed %-------Optional Inputs ------------------------------------------------ % %"minfreq" is the minimum frequency in the ST result(Default=0) %"maxfreq" is the maximum frequency in the ST result (Default=Nyquist) %"samplingrate" is the time interval between samples (Default=1) %"freqsamplingrate" is the frequency-sampling interval you desire in the ST result (Default=1) %Passing a negative number will give the default ex. [s,t,f] = st(data,-1,-1,2,2) %-------Outputs Returned------------------------------------------------ % % st -a complex matrix containing the Stockwell transform. % The rows of STOutput are the frequencies and the % columns are the time values ie each column is % the "local spectrum" for that point in time % t - a vector containing the sampled times % f - a vector containing the sampled frequencies %--------Additional details----------------------- % % There are several parameters immediately below that % the user may change. They are: %[verbose] if true prints out informational messages throughout the function. %[removeedge] if true, removes a least squares fit parabola % and puts a 5% hanning taper on the edges of the time series. % This is usually a good idea. %[analytic_signal] if the timeseries is real-valued % this takes the analytic signal and STs it. % This is almost always a good idea. %[factor] the width factor of the localizing gaussian % ie, a sinusoid of period 10 seconds has a % gaussian window of width factor*10 seconds. % I usually use factor=1, but sometimes factor = 3 % to get better frequency resolution. % Copyright (c) by Bob Stockwell % $Revision: 1.2 $ $Date: 1997/07/08 $ % This is the S transform wrapper that holds default values for the function. TRUE = 1; FALSE = 0; %%% DEFAULT PARAMETERS [change these for your particular application] verbose = TRUE; removeedge= FALSE; analytic_signal = FALSE; factor = 1; %默认值为1 %%% END of DEFAULT PARAMETERS %%%START OF INPUT VARIABLE CHECK % First: make sure it is a valid time_series % If not, return the help message if verbose disp(' '),end % i like a line left blank if nargin == 0 if verbose disp('No parameters inputted.'),end st_help t=0;st=-1;f=0; return end % Change to column vector if size(timeseries,2) > size(timeseries,1) timeseries=timeseries'; end % Make sure it is a 1-dimensional array if size(timeseries,2) > 1 error('Please enter a *vector* of data, not matrix') return elseif (size(timeseries)==[1 1]) == 1 error('Please enter a *vector* of data, not a scalar') return end % use defaults for input variables if nargin == 1 minfreq = 0; maxfreq = fix(length(timeseries)/2); samplingrate=1; freqsamplingrate=1; elseif nargin==2 maxfreq = fix(length(timeseries)/2); samplingrate=1; freqsamplingrate=1; [ minfreq,maxfreq,samplingrate,freqsamplingrate] = check_input(minfreq,maxfreq,samplingrate,freqsamplingrate,verbose,timeseries); elseif nargin==3 samplingrate=1; freqsamplingrate=1; [ minfreq,maxfreq,samplingrate,freqsamplingrate] = check_input(minfreq,maxfreq,samplingrate,freqsamplingrate,verbose,timeseries); elseif nargin==4 freqsamplingrate=1; [ minfreq,maxfreq,samplingrate,freqsamplingrate] = check_input(minfreq,maxfreq,samplingrate,freqsamplingrate,verbose,timeseries); elseif nargin == 5 [ minfreq,maxfreq,samplingrate,freqsamplingrate] = check_input(minfreq,maxfreq,samplingrate,freqsamplingrate,verbose,timeseries); else if verbose disp('Error in input arguments: using defaults'),end minfreq = 0; maxfreq = fix(length(timeseries)/2); samplingrate=1; freqsamplingrate=1; end if verbose disp(sprintf('Minfreq = %d',minfreq)) disp(sprintf('Maxfreq = %d',maxfreq)) disp(sprintf('Sampling Rate (time domain) = %d',samplingrate)) disp(sprintf('Sampling Rate (freq. domain) = %d',freqsamplingrate)) disp(sprintf('The length of the timeseries is %d points',length(timeseries))) disp(' ') end %END OF INPUT VARIABLE CHECK % If you want to "hardwire" minfreq & maxfreq & samplingrate & freqsamplingrate do it here % calculate the sampled time and frequency values from the two sampling rates t = (0:length(timeseries)-1)*samplingrate; spe_nelements =ceil((maxfreq - minfreq+1)/freqsamplingrate) ; f = (minfreq + [0:spe_nelements-1]*freqsamplingrate)/(samplingrate*length(timeseries)); if verbose disp(sprintf('The number of frequency voices is %d',spe_nelements)),end % The actual S Transform function is here: st = strans(timeseries,minfreq,maxfreq,samplingrate,freqsamplingrate,verbose,removeedge,analytic_signal,factor); % this function is below, thus nicely encapsulated %WRITE switch statement on nargout % if 0 then plot amplitude spectrum if nargout==0 if verbose disp('Plotting pseudocolor image'),end pcolor(t,f,abs(st)) end return %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ function st = strans(timeseries,minfreq,maxfreq,samplingrate,freqsamplingrate,verbose,removeedge,analytic_signal,factor); % Returns the Stockwell Transform, STOutput, of the time-series % Code by R.G. Stockwell. % Reference is "Localization of the Complex Spectrum: The S Transform" % from IEEE Transactions on Signal Processing, vol. 44., number 4, % April 1996, pages 998-1001. % %-------Inputs Returned------------------------------------------------ % - are all taken care of in the wrapper function above % %-------Outputs Returned------------------------------------------------ % % ST -a complex matrix containing the Stockwell transform. % The rows of STOutput are the frequencies and the % columns are the time values % % %----------------------------------------------------------------------- % Compute the length of the data. n=length(timeseries); original = timeseries; if removeedge if verbose disp('Removing trend with polynomial fit'),end ind = [0:n-1]'; r = polyfit(ind,timeseries,2); fit = polyval(r,ind) ; timeseries = timeseries - fit; if verbose disp('Removing edges with 5% hanning taper'),end sh_len = floor(length(timeseries)/10); wn = hanning(sh_len); if(sh_len==0) sh_len=length(timeseries); wn = 1&[1:sh_len]; end % make sure wn is a column vector, because timeseries is if size(wn,2) > size(wn,1) wn=wn'; end timeseries(1:floor(sh_len/2),1) = timeseries(1:floor(sh_len/2),1).*wn(1:floor(sh_len/2),1); timeseries(length(timeseries)-floor(sh_len/2):n,1) = time
评论
    相关推荐
    • S transform.rar
      s变换matlab仿真函数及一个简单示例
    • MATLAB图像处理实例详解.rar
      MATLAB图像处理实例详解pdf 关于matlab图像处理很全面,精通必看
    • md5 MD5 加密 实例 java
      md5 MD5 加密 实例 简单md5 MD5 加密 实例 简单
    • 最新PS学习实例,学习技巧
      用ps实例讲解通道抠图法.mht photoshop钢笔路径实用技巧.txt [新手必看的工具使用技巧及基础操作] [Photoshop修复模糊照片的多种方法] [ps修图技巧实用篇] [ps通道调色教程] [ps通道抠图教程] Photoshop入门教程...
    • MOP算法一维信号实例
      MOP算法在一维信号处理上的例子,以及系数度K的自选择
    • givens变换中的cordic算法(矩阵分解)
      givens变换中的cordic算法(矩阵分解)
    • java微信支付实例.zip
      用java技术开发的微信支付开发,开发h5支付。 原生调用js支付。 里面附有公众号开发的官方api,妈的研究了3天才搞出来 遇到了一些问题 1.微信支付必须要用微信的内置浏览器才能访问。 2.需要有支付人的openid,所以...
    • contourlet变换工具箱
      是matlab的contourlet变换的工具箱,代码中有实例,可以很简单的加以调用,需要学习图像处理非常实用
    • 离散余弦变换.rar
      visual c++数字图像处理典型算法及实例,离散余弦变换源码,已经通过测试
    • hvcode.zip
      查看二进制文件的HexView的源代码