changing the plot in GUI manually (only part of the plot)
1 次查看(过去 30 天)
显示 更早的评论
I am trying to implement things from this link-
in a bit more complex gui.. I have a curve plotted, and using a peakfinder function I find all the maxima in the plot,and mark them with an X (using another plot function) but then I want the user to have the ability to correct the location of the maxima if they are wrong, or to erase some X if they are unnecessary.
I can’t understand what should I change or add to make it work to drag only a certain X each step.
in this code it isn't a gui but I still have the same problem
my code-
function main
global data_file
x=0:0.1:100
data_file=sin(x)*5+(rand(100*10+1,1)’-0.5)
starting_sample= 1;
sampling_rate=1;
len = length(data_file);
f=figure(‘NumberTitle’,'off’,'color’,'w’,…
‘Menubar’,'none’);
[picks1,locs1]= findpeaks(data_file(starting_sample:sampling_rate:len),’MINPEAKDISTANCE’,10);
a=axes(‘xlim’,[0 100], ‘ylim’,[-5 5]);
plot(1:sampling_rate:len,data_file(starting_sample:sampling_rate:len));
hold on
p=plot(locs1,picks1,’x',’linewidth’,2,’color’,'r’,'ButtonDownFcn’,@start_drag1);
hold off
set(f,’WindowButtonUpFcn’,@stop_drag1)
function start_drag1(varargin)
set(f,’WindowButtonMotionFcn’,@draging)
end
function draging(varargin)
pt= get(a,’currentpoint’)
set(p,’XData’,pt(1)*[1 1])
end
function stop_drag1(varargin)
set(f,’WindowButtonMotionFcn’,”)
end
end
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!