Azzera filtri
Azzera filtri

Setting and saving markers on plots

5 visualizzazioni (ultimi 30 giorni)
Aaron Smith
Aaron Smith il 30 Mag 2017
Commentato: dpb il 31 Mag 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:
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 Commento
dpb il 30 Mag 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?

Accedi per commentare.

Risposte (1)

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

Accedi per commentare.


Scopri di più su 2-D and 3-D Plots 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!

Translated by