Reputation: 311
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
See picture below
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.
Upvotes: 1
Views: 2843
Reputation: 766
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.
Upvotes: 3