Path: news.mathworks.com!newsfeed-00.mathworks.com!news.kjsl.com!newsfeed.stanford.edu!shelby.stanford.edu!not-for-mail
From: "Linus Utopia" <linus_utopia@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to detect turning points in curves...
Date: Fri, 13 Jul 2007 21:17:18 -0400
Lines: 62
Message-ID: <f798ag$gaa$1@news.Stanford.EDU>
References: <f76kg0$ic0$1@news.Stanford.EDU> <ef5d53f.0@webcrossing.raydaftYaTP> <f76s2p$oib$1@news.Stanford.EDU> <ef5d53f.12@webcrossing.raydaftYaTP>
X-Trace: news.Stanford.EDU 1184375953 16714 127.0.0.1 (14 Jul 2007 01:19:13 GMT)
X-Complaints-To: news@news.stanford.edu
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
Xref: news.mathworks.com comp.soft-sys.matlab:419018




"us" <us@neurol.unizh.ch> wrote in message 
news:ef5d53f.12@webcrossing.raydaftYaTP...
> 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

Wow. Very cool! The positive and negative peaks of the <red> cross-product 
curve shows the turning points of the <blue> data very clearly, even for 
very slight transitions in the data. I also like your "macro" definition of 
cp. I didn't know this usage in Matlab... Thank you! But I still have 
questions:

1. This didn't solve the problem -- how do you detect the positive and 
negative peaks in <red> cross-product curve then?

2. How reliable is this method?