Info
この質問は閉じられています。 編集または回答するには再度開いてください。
Identifying certain x value of a graph when x is not dependent on y?
3 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (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 件のコメント
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!