Setting and saving markers on plots

6 vues (au cours des 30 derniers jours)
Aaron Smith
Aaron Smith le 30 Mai 2017
Commenté : dpb le 31 Mai 2017
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 commentaire
dpb
dpb le 30 Mai 2017
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?

Connectez-vous pour commenter.

Réponses (1)

dpb
dpb le 30 Mai 2017
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 commentaires
Aaron Smith
Aaron Smith le 31 Mai 2017
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 le 31 Mai 2017
Well, that was part of the question...you may want to look at
doc ginput
for user interaction instead of totally automated annotation.

Connectez-vous pour commenter.

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by