From: Valeriy on 25 Jul 2010 13:16 > %the following uses a nested function to share variables > > PlotHandle = plot(rand(10,1)); > > Xd = get(PlotHandle,'XData'); > Yd = get(PlotHandle,'YData'); > > PointNum = 1; > MarkHandle = line(Xd(PointNum), Yd(PointNum), '+'); > > set(gcf, 'KeyPressFcn', {@MyKeyFcn}); > > function MyKeyFcn(src, event) > switch event.Key > case {'uparrow', 'rightarrow'}: > if PointNum < length(Xd); PointNum = PointNum + 1; end > case {'downarrow', 'leftarrow'}; > if PointNum > 1; PointNum = PointNum - 1; end > end > set(MarkHandle, 'XData', Xd(PointNum), 'YData', Yd(PointNum)); > %then do whatever needed to "read" the data point to you > end > > end Thank you for this information. Could you give idea how to pass information about selected PointNum to calling function? I have tested different ways (declaring global variable, using handle structure), but it did not works, perhaps by my weak knowledge of corresponding methods. Vale
|
Pages: 1 Prev: Adaptive modulation and coding Next: R2010b Prerelease is Live |