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

📄 compare.m

📁 一种新的时频分析方法的matlab源程序。
💻 M
字号:
function h=compare(c1,c2,c1i,c2i,c1j,c2j,c1s,c2s);
% COMPONENTS/COMPARE compares components in two Components structures
% by plotting them on the same axes.
%
% Usage: (brackets indicate optional parameters)
%  h=compare(c1,c2[,c1i][,c2i][,c1j][,c2j][,c1s][,c2s]);
%
% Input:
%  c1, c2   - Components structures to compare
%  c1i, c2i - start plotting at the i-th component (from 1)
%  c1j, c2j - end plotting at the j-th components (from 1)
%  c1s, c2s - style string to pass to 'plot' (see help for PLOT)
%
% Output: (optional)
%  h        - handle to the figure used
%
% Defaults:
%  The number of components to plot for each Components input must be the
%  same. In all cases, COMPARE will attempt to fill in the unspecified values
%  so that this is the case. However, some situations will be impossible to
%  accomodate, so you will get an error: 'Plot bounds out of range.' So in
%  most cases you can give COMPARE the minimum amount of information to plot 
%
%  If only the two Components structures are specified, COMPARE will plot all
%  components of the smaller structure.
%  If one starting index is additionally given, COMPARE will start plotting
%  both structures at that index.
%  If the other starting index is additionally given, COMPARE will honor
%  both starting indices and compute corresponding ending indices to make
%  the number of plots match.
%
%  If no style strings are given, COMPARE will default to blue for c1 and
%  green for c2.

% Kenneth C. Arnold (for NASA GSFC), 2004-08-06

if nargin < 2
    error('MATLAB:minrhs', 'Not enough input arguments.');
end
if nargin < 3; c1i=[]; end
if nargin < 4; c2i=[]; end
if nargin < 5; c1j=[]; end
if nargin < 6; c2j=[]; end
if nargin < 7; c1s=[]; end
if nargin < 8; c2s=[]; end

if isempty(c1i); c1i=1; end
if isempty(c2i); c2i=c1i; end
if isempty(c1j); c1j=min([length(c1.d),length(c2.d)-c2i+1]); end
if isempty(c2j); c2j=c2i+c1j-c1i; end
if isempty(c1s); c1s='b'; end
if isempty(c2s); c2s='g'; end

if c1i < 1 | c2i < 1 | c1j > max(size(c1.d)) | c2j > max(size(c2.d)) | c1j < c1i | c2j < c2i
    error('hht:outOfRange', 'Plot bounds out of range.');
end

numplots = c1j - c1i + 1;
if numplots ~= c2j - c2i + 1
    error('hht:dimnotmatch', 'Number of plots does not match');
end

% Set plotting area
subplot(numplots, 1, 1);

for n=0:numplots-1
    subplot(numplots, 1, n+1);
    n1 = n+c1i;
    n2 = n+c2i;
    plot(linspace(c1.d(n1).stime, c1.d(n1).etime, max(size(c1.d(n1).c))), c1.d(n1).c,c1s);
    hold on;
    plot(linspace(c2.d(n2).stime, c2.d(n2).etime, max(size(c2.d(n2).c))), c2.d(n2).c,c2s);
    hold off
    ymin1 = min(c1.d(n1).c);
    ymax1 = max(c1.d(n1).c);
    ymin2 = min(c2.d(n2).c);
    ymax2 = max(c2.d(n2).c);
    ymin = min([ymin1 ymin2]);
    ymax = max([ymax1 ymax2]);
    if ymin == ymax
        ymin = ymin-.1;
        ymax = ymax+.1;
    end
    axis([min([c1.stime c2.stime]) max([c1.etime c2.etime]) ymin ymax]);
    ylabel([inputname(1) '(' num2str(n1) ')/' inputname(2) '(' num2str(n2) ')']);
end
subplot(numplots,1,1);
if c1i==1 & c1j==max(size(c1.d)) & c2i==1 & c2j==max(size(c2.d))
    title([inputname(1) ' and ' inputname(2)]);
else
    title([inputname(1) '(' num2str(c1i) ':' num2str(c1j) ') and ' inputname(2) '(' num2str(c2i) ':' num2str(c2j) ')']);
end
set(gcf,'NextPlot','replace');
if nargout == 1
    h=gcf;
end

⌨️ 快捷键说明

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