⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 plot_modwt_coef2.m

📁 时间序列分析中很用的源码,书的原名为时间序列分析的小波方法.
💻 M
📖 第 1 页 / 共 2 页
字号:
WplotFrame.width = masterPlotFrame.width;WplotFrame.height = masterPlotFrame.height;  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Transform data for plotting%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if (plot_WJt)  [N, J] = size(WJt);  if(~exist('level_range', 'var') || isempty(level_range))    J0 = J;  else    if(~exist('J0', 'var') || isempty(J0))      error(['Must specify J0 if specifying level_range']);    end  endelse  N = length(VJ0t);  if (~exist('J0', 'var') || isempty(J0))    error(['Must specify J0 if plotting only VJ0t (i.e. WJt = ' ...           '[])']);  endendW = [];Wlabels = {};WTag = {};jj = 0;if (plot_WJt)  if(~exist('level_range', 'var') || isempty(level_range))    level_range = 1:J;  end  for (j = level_range)    jj = jj + 1;    nuHj = advance_wavelet_filter(wtfname, j);    W(:,jj) = circshift(WJt(:,j), nuHj);    Wlabels{jj} = ['T^{', int2str(nuHj), '}\bfW\rm_{', int2str(j), '}'];    WTag{jj} = ['W', int2str(j)];  endendif (plot_VJ0t)  jj = jj + 1;  nuGj = advance_scaling_filter(wtfname, J0);  if (subtract_mean_VJ0t)    VJ0t = VJ0t - mean(VJ0t);    label_str = ['T^{', int2str(nuGj), ...                 '}(\bfV\rm_{', int2str(J0), '}-<\bfV\rm_{', int2str(J0), '}>)'];  else    label_str = ['T^{', int2str(nuGj), '}\bfV\rm_{', int2str(J0), '}'];  end      W(:,jj) = circshift(VJ0t, nuGj);  Wlabels{jj} = label_str;  WTag{jj} = ['V', int2str(J0)];endWplotAxesPropName = {};WplotAxesPropVal = {};if (plot_WJt || plot_VJ0t)    if (exist('WplotAxesProp', 'var') && ~isempty(WplotAxesProp))    % Overide default values for Xmin, Xmin (= YLim min and max for Xplot)    if (isfield(WplotAxesProp, 'YLim'))      ylim = WplotAxesProp.YLim;    end    % Populate cell arrays for Wplot axes names and properties    axes_field_names = fieldnames(WplotAxesProp);    nfields = length(axes_field_names);        for (i = 1:nfields)      fname = axes_field_names{i};      WplotAxesPropName(i) = {fname};      fval = WplotAxesProp.(fname);      WplotAxesPropVal(i) = {fval};    end  endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Setup up x-axis%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% If xaxis is not specified, use the sample pointsif (~exist('xaxis', 'var') || isempty(xaxis))  xaxis = (1:N);endif (exist('xaxis_range', 'var') && ~isempty(xaxis_range))  indices = find(xaxis >= xaxis_range(1) & xaxis <= xaxis_range(end));  xaxis = xaxis(indices);  W = W(indices,:);  X = X(indices,1);else  xaxis_range = [];endxaxis_xmin = min(xaxis);xaxis_xmax = max(xaxis);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Parse the Xplot options%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if (plot_X)  % Check that length(X) == length(W)  if (length(X) ~= length(W))    error(['Length of X must be equal nrows of WJt and VJ0t']);  end  % Initialize default values  Xmin = min(X);  Xmax = max(X);  XplotAxesPropName = {};  XplotAxesPropVal = {};    if (exist('XplotAxesProp', 'var') && ~isempty(XplotAxesProp))    % Overide default values for Xmin, Xmin (= YLim min and max for Xplot)    if (isfield(XplotAxesProp, 'YLim'))      ylim = XplotAxesProp.YLim;      Xmin = ylim(1);      Xmax = ylim(2);    end    % Populate cell arrays for Xplot axes names and properties    axes_field_names = fieldnames(XplotAxesProp);    nfields = length(axes_field_names);        for (i = 1:nfields)      fname = axes_field_names{i};      XplotAxesPropName(i) = {fname};      fval = XplotAxesProp.(fname);      XplotAxesPropVal(i) = {fval};    end  endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  Override x-axis min, max values%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if (exist('XplotAxesProp', 'var'))  % Overide default values for xaxis_xmin, xaxis_xmax from XplotAxesProp  if (isfield(XplotAxesProp, 'XLim'))    xlim = XplotAxesProp.XLim;    xaxis_xmin = xlim(1);    xaxis_xmax = xlim(2);  endelseif (exist('WplotAxesProp', 'var'))  % Overide default values for xaxis_xmin, xaxis_xmax from WplotAxesProp  if (isfield(WplotAxesProp, 'XLim'))    xlim = WplotAxesProp.XLim;    xaxis_xmin = xlim(1);    xaxis_xmax = xlim(2);  endelse  % Do nothing - no overrideend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Setup up subplots%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%[npts, nlev] = size(W);nplots = nlev;if (plot_X)  nplots = nplots + 1;endiplot = 0;ha_list = [];%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Create Xplot%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%if (plot_X)  iplot = iplot + 1;  haX = subplot(nplots, 1, nplots);  % Create a subplot for X  set(gca, 'Tag', 'Xplot',  ...           'XAxisLocation', 'bottom', ...           'YAxisLocation', 'left');  hl = plot(xaxis, X);  set(gca, XplotAxesPropName, XplotAxesPropVal);  set(gca, 'XLim', [xaxis_xmin xaxis_xmax]);  set(gca, 'YLim', [Xmin Xmax]);  htext = get(gca, 'YLabel');  Position = get(htext, 'Position');    offset = xaxis_xmin - Position(1);  ylabel_xpos = xaxis_xmax + offset;  ylabel_ypos = Position(2);  x_ylabel_xpos = ylabel_xpos;  htext = text(ylabel_xpos, ylabel_ypos, '\bfX');  if (exist('xlabel_str', 'var') && ~isempty(xlabel_str))    xlabel(xlabel_str)  endend%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%   Create Wplot%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%for (j = 1:nlev)  iplot = iplot + 1;  haW = subplot(nplots, 1, nplots-iplot+1);    ha_list = [ha_list, haW];  set(haW, 'Tag', WTag{j});    hl = plot(xaxis, W(:,j));  set(gca, WplotAxesPropName, WplotAxesPropVal);  set(gca, 'XLim', [xaxis_xmin xaxis_xmax]);  % Plot the MODWT coefficients  set(haW, 'XTickLabel', {});  if (~isempty(scale_str))    htext = ylabel(scale_str{j}, ...                   'VerticalAlignment', 'Middle', ...                   'HorizontalAlignment', 'Right', ...                   'Rotation', 0);  end      htext = get(gca, 'YLabel');  Position = get(htext, 'Position');    offset = xaxis_xmin - Position(1);%  ylabel_xpos = xaxis_xmax + offset;  ylabel_xpos = xaxis_xmax;  ylabel_ypos = Position(2);    htext = text(x_ylabel_xpos, ylabel_ypos, Wlabels{j});  set(htext, ...      'VerticalAlignment', 'Middle', ...      'HorizontalAlignment', 'Left');        if (~plot_X && j == 1)    % If no Xplot ...    %   - add xaxis label if string value provided    if (exist('xlabel_str', 'var') && ~isempty(xlabel_str))      xlabel(xlabel_str)    end    %  - turn on tickmark lablels if overrided.    if (isfield(WplotAxesProp, 'XTickLabel'))      set(haW, 'XTickLabel', WplotAxesProp.XTickLabel);    end  endendif (exist('title_str', 'var') && ~isempty(title_str))  suptitle(title_str)end% TODO:  Add plotting of modwt boundaries.%%   This code snippet is example for plot_modwt_coef.%%% if (plot_modwt_boundary && isempty(xaxis_range))%%%   overplot_modwt_cir_shift_coef_bdry(haW, WJt, VJ0t, wtfname, ...%%%                                      xaxis, J0, level_range);%%% endif (nargout > 0) hWplotAxes = ha_list;endif (nargout > 0) hXplotAxes = haX;endreturn

⌨️ 快捷键说明

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