From: Walter Roberson on 12 May 2010 13:27 EE Student wrote: > "someone" <someone(a)somewhere.net> wrote in message > <hseia9$3t$1(a)fred.mathworks.com>... >> "EE Student " <np7(a)cec.wustl.edu> wrote in message >> <hsei0s$aoi$1(a)fred.mathworks.com>... >> > "Dimitris Valapetrou" <diastro(a)email.com> wrote in message >> <hseg14$1jn$1(a)fred.mathworks.com>... >> > > How can i calculate the first three maximum values of a signal > True, I guess i didnt see the way to implement it with max short of > writting it into a recursion or something similar (which seems to be > what you suggested) and thought that would be overkill as opposed to > just sorting. Keep in mind that algorithmic "average case" "order" for sort() is N*log(N) (where N is the number of elements in the vector), but that the algorithmic order for M passes of "max" is M*N. The further that M is from log(N), the more efficient relatively doing M scans over the matrix will be. exp(3) is roughly 10, so for more than 10 or so elements, using max() three times would be faster than sort().
From: someone on 12 May 2010 13:34 Walter Roberson <roberson(a)hushmail.com> wrote in message <dyBGn.6314$HG1.1266(a)newsfe21.iad>... > EE Student wrote: > > "someone" <someone(a)somewhere.net> wrote in message > > <hseia9$3t$1(a)fred.mathworks.com>... > >> "EE Student " <np7(a)cec.wustl.edu> wrote in message > >> <hsei0s$aoi$1(a)fred.mathworks.com>... > >> > "Dimitris Valapetrou" <diastro(a)email.com> wrote in message > >> <hseg14$1jn$1(a)fred.mathworks.com>... > >> > > How can i calculate the first three maximum values of a signal > > > True, I guess i didnt see the way to implement it with max short of > > writting it into a recursion or something similar (which seems to be > > what you suggested) and thought that would be overkill as opposed to > > just sorting. > > Keep in mind that algorithmic "average case" "order" for sort() is > N*log(N) (where N is the number of elements in the vector), but that the > algorithmic order for M passes of "max" is M*N. The further that M is > from log(N), the more efficient relatively doing M scans over the matrix > will be. exp(3) is roughly 10, so for more than 10 or so elements, using > max() three times would be faster than sort(). Thanks for the insight Walter. You learn something new everyday. I would have guessed more like thousands rather than tens.
From: Dimitris Valapetrou on 15 May 2010 14:09 "Dimitris Valapetrou" <diastro(a)email.com> wrote in message <hseg14$1jn$1(a)fred.mathworks.com>... > How can i calculate the first three maximum values of a signal using the max fuction? > > thanks for your help! Thanks a lot guys! Your replies really helped me out. i finally used the sort() function as the most efficient.
First
|
Prev
|
Pages: 1 2 Prev: Splitting audio into frames Next: How to assign a variable name to a structure? |