function[varargout]=longridge(struct,N)
%LONGRIDGE  Removes ridge lines of length than a specified length.
%
%   LONGRIDGE(STRUCT,N) removes all ridges of less than N periods in
%   length from the ridge struture STRUCT.
%
%   STRUCT may be generated by either RIDGEWALK or ELLRIDGE.
%
%   Usage: []=longridge();
%   __________________________________________________________________
%   This is part of JLAB --- type 'help jlab' for more information
%   (C) 2008 J.M. Lilly --- type 'help jlab_license' for details

use struct

phi=unwrap(angle(wr));
nperiods=frac(1,2*pi)*(max(phi)-min(phi));

%if nargin==1
%    N=maxmax(nperiods);
%end
        
phi=unwrap(angle(wr));
nperiods=frac(1,2*pi)*(max(phi)-min(phi));
index=find(nperiods>N);

names=fieldnames(struct);
for i=1:length(names)
    x=getfield(struct,names{i});
    if size(x)==size(wr)
        struct=setfield(struct,names{i},vindex(x,index,2));
    end
end