如何在matlab中标记具有峰的图 [英] How to label plot having peaks in matlab

查看:335
本文介绍了如何在matlab中标记具有峰的图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试标记具有峰值的XRD数据,并且希望从数据数组中对其进行标记:

I'm trying to label my XRD data which have peaks, and I want to label it from my array of data:

  peak label  
    ab
    ac
    ad
    cb
    bb
    ba

请参见下图

我还希望这些标签在峰的顶部垂直对齐. 我尝试了findpeaks函数,但是它不起作用.

I also want those labels to be vertically aligned on the top of the peaks. I tried the findpeaks function but it doesn't work.

推荐答案

尝试一下(但是您需要一个信号处理工具箱):

Try this (but you need to have a Signal Processing Toobox):

x = [1 2 3 4 5 6 7 8 9] 
y = [1 4 2 7 3 9 5 10 2]
[peak, peakId] = findpeaks(y); %find peaks in your serie
figure(1) 
plot(x, y)
lbalph=('a':'z').'
lb=strcat(Alphabet(1),lbalph(1:length(peak))) %Create a label matrix
lb = num2cell(lb,2) % Convert to cell array
lbid = 1:length(lb)
text(x(peakId), peak, lb(lbid),'Rotation',90) % label the peak with your lb matrix

有了索引峰值,就可以根据需要进行标记.

As you have the index peaks, you can labeled as you want.

这篇关于如何在matlab中标记具有峰的图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆