MATLAB Answers

Translated by

このページのコンテンツは英語から自動翻訳されています。自動翻訳をオフにする場合は「<a class="turn_off_mt" href="#">ここ</a>」をクリックしてください。

Stephen
0

Identifying certain x value of a graph when x is not dependent on y?

Stephen
さんによって質問されました 2017 年 3 月 13 日
最新アクティビティ Star Strider
さんによって 回答されました 2017 年 3 月 13 日
Hi, I have plotted 2 columns of data from an excel sheet, I have identified several peaks and I would like to know the times associated with these peaks without just zooming in on each value. Basically is there a way to extract an x value given the graph, even though the x and y values are independent?
Similar code would be;
Time = xlsread('Data.xlsx', 'C2:C5000');
Time = Time/500;
Activity = xlsread('Data.xlsx', 'E2:E5000');
FilterActive = sgolayfilt(Activity, 5, 9); % can be removed
peaks = findpeaks(FilterActive, 'MinPeakHeight', 0.4);
plot(Time, FilterActive)
Im very new and inexperienced with coding, so any help or suggestions are welcome and appreciated, thanks.

  0 件のコメント

サインイン to comment.

1 件の回答

回答者: Star Strider
2017 年 3 月 13 日

Ask for a second output from findpeaks.
If you want the indices of the peaks, just use:
[peaks, peak_loc_idx] = findpeaks(FilterActive, 'MinPeakHeight', 0.4);
The ‘x’ values (in the actual units of ‘x’) will then be:
xval = x(peak_loc_idx);
corresponding to the ‘x’ value at each peak.
There are other ways to get the ‘x’ values directly. See the documentation for findpeaks for details.

  0 件のコメント

サインイン to comment.



Translated by