separating the data, peaks and troughs, NaN

1 Ansicht (letzte 30 Tage)
Borhan
Borhan am 30 Nov. 2013
Kommentiert: Image Analyst am 30 Nov. 2013
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

Antworten (1)

Image Analyst
Image Analyst am 30 Nov. 2013
You mean like this:
m2 = m(~isnan(m)) % Pull out non-nan values.
  2 Kommentare
Image Analyst
Image Analyst am 30 Nov. 2013
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 am 30 Nov. 2013
The indexes of your array (that long array that you got somehow) that are non nans is given by
nonNanIndexes = find(~isnan(m));

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by