use plot to receive user input
62 次查看(过去 30 天)
显示 更早的评论
Hello, I want to plot a set of data points, and have the user click on the plot at a certain point in the line itself, and based on the selection, set a particular variable.
I guess the plot function uses a similar procedure to indicate the x and y position when I click on it- if there is a way to get the x coordinate saved in a variable of my choosing, that will work for me.
thanks in advance for your help.
sam
0 个评论
采纳的回答
更多回答(1 个)
dpb
2014-5-22
a) [~,i]=min(abs(x-fun));
b) i = interp1(fun,1:length(fun),x,'nearest');
Will leave as "exercise for the student" the precise "how" of both altho the first is pretty obvious... :)
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!