Setting and saving markers on plots

3 次查看(过去 30 天)
Aaron Smith
Aaron Smith 2017-5-30
评论: dpb 2017-5-31
I have a plot in a GUI window. I would like to set markers to signify the beginning and end in a peak on the plot. I know that it is possible to set a marker from this question on Mathworks: https://uk.mathworks.com/matlabcentral/answers/119402-how-to-set-a-marker-at-one-specific-point-on-a-plot-look-at-the-picture
I need to know if it is possible to set multiple marks, one for the beginning and end points of a peak. As well as this, there may be more than one peak in my plot and these peaks too will need to be marked so that the area under each curve can be calculated. Is this possible using the method in the question above? Is it possible to then save the spatial location of these markers so that they can be placed onto other plots?
  1 个评论
dpb
dpb 2017-5-30
Well, the answer is "yes" but there are multiple possible ways/objectives outlined in the answers to the above question. Which do you have in mind?

请先登录,再进行评论。

回答(1 个)

dpb
dpb 2017-5-30
You might look at the code in Answer to a slightly different question just the other day where I drew a plot that does something like you're asking...so I'll just duplicate the pertinent section here and if the crystal ball happens to be working, then...
>> load mtlb % a sample dataset
>> select = mtlb(1001:1200); % and tiny subset therefrom
>> x=1:length(select); % corollary x variable
>> [pks,locs,wdths]=findpeaks(select,1:length(select),'MinPeakHeight',2); % analyze
>> plot(x,select) % plot
>> hold on
>> hL=plot(locs,pks,'r*'); % mark the peak locations
>> pk1=[locs(1)-fix(wdths(1)):locs(1)+ceil(wdths(1))]; % set the range for the first peak
>> plot(x(pk1),select(pk1),'r-') % and highlight it
>>
Above yields
The section that finds/marks the first FWHM peak area can be easily automated for all the rest as well; I just used the first subscript for example...
  2 个评论
Aaron Smith
Aaron Smith 2017-5-31
Does this allow for the user to select where the peaks are on the plot or is it programmatic to find the peaks? An important part of what i need is setting where the peaks begin and end
dpb
dpb 2017-5-31
Well, that was part of the question...you may want to look at
doc ginput
for user interaction instead of totally automated annotation.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by