separating the data, peaks and troughs, NaN

2 次查看(过去 30 天)
I had bunch of data from a cyclic load on mice bone. The data is, thus, fluctuating with an overall downward trend. I managed to find the peaks and troughs of these data at each cycle, putting them in a vector, while the rest of the data is assigned 0 or NaN. Now, I need to separate them in two vectors: i.e vector peaks and trough peaks. I was wondering if any could help me in this respect. Any guideline is highly appreciated. Here is the sample point of 100 data: NaN NaN NaN NaN NaN NaN NaN NaN -4.6943 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN -4.3718 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN -4.7253 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN -4.4214 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN -4.7377 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN -4.4400 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN -4.7501 NaN NaN Thanks

回答(1 个)

Image Analyst
Image Analyst 2013-11-30
You mean like this:
m2 = m(~isnan(m)) % Pull out non-nan values.
  2 个评论
Image Analyst
Image Analyst 2013-11-30
Borhan's "Answer" moved here because it was really a comment to me rather than an answer to his original question:
Thank you very much for your prompt reply. actually I have 3 columns of data (time, displacement, force) and I want to detect peaks and troughs of these data as well as their coincident time. What you mentioned just spits out the extremums (peaks and troughs) while I want to have these data separately (including their index). Thanks again for your reply.
Image Analyst
Image Analyst 2013-11-30
The indexes of your array (that long array that you got somehow) that are non nans is given by
nonNanIndexes = find(~isnan(m));

请先登录,再进行评论。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by