Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Identifying Upward and Downward Trends
Replies: 5   Last Post: Apr 5, 2013 12:50 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Konstantine

Posts: 34
Registered: 5/3/11
Re: Identifying Upward and Downward Trends
Posted: Apr 3, 2013 1:05 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I think I have a direction:

If I use the function peakdet (http://www.billauer.co.il/peakdet.html) I can find the maximums and minimums of the plot. I can then find the first minimum and the maximum value that follows it. After I make sure that the length of the two vectors match, I find the difference between the subsequent maximums and minimums. Where there is an upward trend, the variability of the differences is much higher than when there is a downward trend. Basically, when there is a upward trend there are a lot more data points between maximums and the minimums behind them. Whereas on downward trending data, there are typically very few (mostly no) data points between maximums and the minimums preceding them.

You can use the data I supplied earlier to test this out, swapping 'upward' and 'downward' as needed.

[maxtab, mintab] = peakdet(upward,10);
%plot(upward;hold on; plot(mintab(:,1), mintab(:,2), 'g*'); plot(maxtab(:,1), maxtab(:,2), 'r*');

compMaxes = find(maxtab(:,1)>mintab(1,1));
numMax = numel(compMaxes);
numMin = numel(mintab(:,1));
if numMax > numMin
var(maxtab(compMaxes(1:numMin,1)) - mintab(:,1))
elseif numMax < numMin
var(maxtab(compMaxes,1) - mintab(1:numMax,1))
else
var(maxtab(compMaxes,1) - mintab(:,1))
end

I'm sure this can be cleaned up a lot, but it works for now. Any direction would be very appreciated.

Thanks,
K



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.