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