The Math Forum

Search All of the Math Forum:

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

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

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

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 ]

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 ( 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))
var(maxtab(compMaxes,1) - mintab(:,1))

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


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

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.