필터 지우기
필터 지우기

use plot to receive user input

조회 수: 37 (최근 30일)
Samuel
Samuel 2014년 5월 21일
답변: dpb 2014년 5월 22일
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

채택된 답변

dpb
dpb 2014년 5월 21일
doc ginput % maybe?
  댓글 수: 1
Samuel
Samuel 2014년 5월 22일
yup, I think I can work with this, thanks. If I may ask another question- I am trying to get one of the coordinates from this ginput, and search for a value close to this in another array, what would be the approach to accomplish this? For instance, if
array fun=[50 53 60 64]
[x,y]=ginput;
If I extracted a coordinate of 55,80 from ginput, and want to use just the x coordinate and get the index number in array fun that is closest to that point, what would be the steps?
thanks in advance.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

dpb
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... :)

카테고리

Help CenterFile Exchange에서 Visual Exploration에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by