findpeaksを使って検出されたピークのX値をプロットに加えたい。 I want to add the X values of the peaks on the figure.
60 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
実験で得られたスペクトルのピーク位置をfindpeaksを使って見つけたはいいものの、そのピークのX値をプロットのマーカーに表示させたいのですが可能でしょうか?
Would you tell me how to add the X values of the peaks on the figure?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1180473/image.png)
0 Commenti
Risposte (1)
Hernia Baby
il 4 Nov 2022
text関数をご使用ください
data = [25 8 15 5 6 10 10 3 1 20 7];
plot(data)
ここで座標を取得します
[pks,locs] = findpeaks(data);
テキストをプロットしていきます
hold on
for ii = 1:length(locs)
text(locs(ii),pks(ii),num2str(locs(ii)))
end
3 Commenti
Atsushi Ueno
il 5 Nov 2022
上記の例にもある様に、findpeaks関数が持つ描画機能(主な違いは▼の表示)を使う事を提案します。その場合同じfindpeaks関数を2度実行する必要があります。また、text関数の引数を列ベクトルにすればforループを回す必要がありません。
data = [25 8 15 5 6 10 10 3 1 20 7];
[pks,locs] = findpeaks(data); % 一回目(ピーク値pksとそのインデックスlocsを得る為)
findpeaks(data); % 二回目(グラフを描画する為)
text(locs+.2, pks, num2str(locs')); % 表示位置をちょっと(0.2)ずらす
Vedere anche
Categorie
Scopri di più su 記述統計 in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!