cs1h Posted November 10, 2009 Share Posted November 10, 2009 Hi, I am trying to find a way of finding the highs and lows on a graph line, the line points will be given in the form (x,y). Does anyone know a way to do this or a tutorial that will show me how to do this? Thanks, Cs1h Link to comment https://forums.phpfreaks.com/topic/180966-reading-waves/ Share on other sites More sharing options...
gevans Posted November 10, 2009 Share Posted November 10, 2009 How will you be getting the data, can you give an example? XML JSON other...? Link to comment https://forums.phpfreaks.com/topic/180966-reading-waves/#findComment-954785 Share on other sites More sharing options...
Mchl Posted November 10, 2009 Share Posted November 10, 2009 If you're after global extremes, just use min and max Link to comment https://forums.phpfreaks.com/topic/180966-reading-waves/#findComment-954787 Share on other sites More sharing options...
cs1h Posted November 10, 2009 Author Share Posted November 10, 2009 The data will be read in by translating a line in the form of an image into co-ordinates, the data will probably be stored in an array. I want to find all the highs and lows on the graph, so if it was a wave it would find the peaks and dips in it. Link to comment https://forums.phpfreaks.com/topic/180966-reading-waves/#findComment-954790 Share on other sites More sharing options...
gevans Posted November 10, 2009 Share Posted November 10, 2009 The data will be read in by translating a line in the form of an image into co-ordinates, the data will probably be stored in an array. I want to find all the highs and lows on the graph, so if it was a wave it would find the peaks and dips in it. In which case you'll want to refer to Mchl's post Link to comment https://forums.phpfreaks.com/topic/180966-reading-waves/#findComment-954794 Share on other sites More sharing options...
cs1h Posted November 10, 2009 Author Share Posted November 10, 2009 Would this work if there are multiple peaks and dips? Link to comment https://forums.phpfreaks.com/topic/180966-reading-waves/#findComment-954797 Share on other sites More sharing options...
Mchl Posted November 10, 2009 Share Posted November 10, 2009 No, it won't Let's have an example data y 0, 1, 2, 1, 0,-1, 0, 1, 2, 1, 2, 1, 0 x 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12 Now you need to calculate a difference between each pair of consecutive data dy 0, 1, 1,-1,-1,-1, 1, 1, 1,-1, 1,-1,-1 x 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12 The local minimums and maximums are whenever there is a change of sign in the next element of this array. So on positions 2,5,8,9, and 10 Link to comment https://forums.phpfreaks.com/topic/180966-reading-waves/#findComment-954844 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.