Hi,
I used "findpeaks" to find the IDs of all the peaks in my data. I need for each peak to find the average of five elements before it. the problem is that some of the peaks don't have five elements before it (say the second value is a peak, therefore, there is only one value before it). How can I tell matlab to average whatever is available but not more than 5 elements?
ANSWER
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
data_before = Yourdata(max(1, idx-5) : idx-1)
Note that in the case that idx is 1, this will give the empty result, as "empty" is all of the data that is available before the location.
Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.
data_before = Yourdata(max(1, idx-5) : idx-1)
Note that in the case that idx is 1, this will give the empty result, as "empty" is all of the data that is available before the location.
Comments
Post a Comment