seq2cell.m

来自「轨迹聚类工具箱及其相关说明和文章(台风路径分类等)。如有问题可与wyljess@」· M 代码 · 共 44 行

M
44
字号
function [y,x] = seq2cell(Y,Seq,X)
%Seq2Cell  Convert curves in Sequence form to Cell form
%
%   [y,x] = Seq2Cell(Y,Seq,[X])

% Scott J Gaffney   20 October 2003
% Department of Information and Computer Science
% University of California, Irvine.
%
% Changes
% -----------------------------------


PROGNAME = 'Seq2Cell';
if (~nargin)
  try; help(PROGNAME); catch; end
  return;
end

x=[];
X = cexist('X',[]);
n = length(Seq)-1;
y = cell(1,n);
if (nargout>1)
  x = cell(1,n);
end

if (isempty(x))
  for i=1:n
    y{i} = Y(Seq(i):Seq(i+1)-1,:);
  end
else
  for i=1:n
    y{i} = Y(Seq(i):Seq(i+1)-1,:);
    if (isempty(X))
      ni = Seq(i+1)-Seq(i);
      x{i} = (0:ni-1)';
    else
      x{i} = X(Seq(i):Seq(i+1)-1);
    end
  end
end

⌨️ 快捷键说明

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