From: <HIDDEN>
Path: news.mathworks.com!newsfeed-00.mathworks.com!webcrossing
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to detect turning points in curves...
Message-ID: <ef5d53f.12@webcrossing.raydaftYaTP>
Date: Fri, 13 Jul 2007 12:07:42 -0400
References: <f76kg0$ic0$1@news.Stanford.EDU> <ef5d53f.0@webcrossing.raydaftYaTP> <f76s2p$oib$1@news.Stanford.EDU>
Lines: 46
NNTP-Posting-Host: 130.60.28.29
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Xref: news.mathworks.com comp.soft-sys.matlab:418950



Linus Utopia:
<SNIP cross-talk...

> Are you suggesting a hack...

not really

% create some data
% ...a skeleton
     y=[5,3,2,0,0,0,0,0,0,0,-1,-3,-5,-5,-6].';
     x=(1:numel(y)).';
% ...slightly enhanced
     xs=(x(1):.2:x(end)).';
     ys=interp1(x,y,xs,'spline');
% the engine
% ...macro of a poor man's 2d cross product
     cp=@(u,v)u(:,1).*v(:,2)-u(:,2).*v(:,1);
     dx=diff(xs);
     dy=diff(ys);
     dd=[dx,dy];
     r=cp(dd(1:end-1,:),dd(2:end,:));
% the result on display
% - note: some vals are scaled for clarity
     lh=zeros(3,1);
     lh(1)=line(xs,ys,...
           'markerfacecolor',[0,0,1],...
           'color',[0,0,1]);
     lh(2)=line(xs(2:end-1),500*r,...
           'markerfacecolor',[1,0,0],...
           'color',[1,0,0]);
     lh(3)=line(xs(2:end),10*dy,...
           'markerfacecolor',[0,1,0],...
           'color',[0,1,0]);
     set(lh,'marker','o',...
            'markersize',4);
     line(x([1,end]),[0,0],-[1,1],...
         'color',.85*[1,1,1]);
     legend(lh,'data','cross','diff');

now, look at the <red> cross-product...
- how does it change with respect to the <blue> data
- how easy would it be to check whether all are >=0
- how does it compare with the diff

just a thought
us