필터 지우기
필터 지우기

Mouse speed (frustratingly) slow when using ginput in R2015b

조회 수: 8 (최근 30일)
Nadia
Nadia 2016년 1월 6일
편집: Dmitry Kaplan 2018년 10월 3일
I often use ginput in my scripts to select a region in which to search for local maxima in my data sets.
Something like this:
x = -10:10;
y = .01*x.^4-x.^3-2*x.^2+20*x-1;
figure('units','normalized','outerposition',[0 0 1 1])
plot(x,y);
[Xs, ~] = ginput(2);
I1 = find(x < Xs(1), 1);
I2 = find(x > Xs(2), 1);
LocalMax = max(y(I1:I2));
Now that I've upgraded to R2015b, the pointer moves very slowly when I'm using ginput. I've noticed this only occurs when I force the figure window to be full-screen, but I need the window to be large so I can see my data clearly.
  댓글 수: 1
Nam Hoang Le
Nam Hoang Le 2016년 9월 16일
I have the same problem. Someone can help. I have Core I7, RAM 8GB, so I do not think it is because of PC

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

답변 (4개)

Benigno Barbés Fernández
Benigno Barbés Fernández 2017년 3월 5일
I have the same problem. It began when I upgraded from 2014b to 2016b. Any hint?

Yura Polyachenko
Yura Polyachenko 2017년 8월 12일
I had the same problem. I needed ginput(1) and finally found that it can be replaced with
function axes_ButtonDownFcn(hObject, eventdata)
...
crd = get (gca, 'CurrentPoint');
y = crd(1,2);
x = crd(1,1);
...
end
if you need N points it can be something like this
% these vars are some kind of global vars, e.g. handles can be used.
N = 10;
ind = 0;
x = zeros(1,N);
y = zeros(1,N);
function axes_ButtonDownFcn(hObject, eventdata)
if(ind<N)
ind = ind+1;
c = get (gca, 'CurrentPoint');
y(ind) = c(1,2);
x(ind) = c(1,1);
else
% we are here after getting N points
N = 0;
do_smth_with_point(x,y,some_data);
end
end
Try to play with 'CurrentPoint' somehow anyway

Jan
Jan 2017년 8월 12일

Benigno Barbés Fernández
Benigno Barbés Fernández 2018년 8월 27일
Hi.
I tried the solution of Yura (using the function axes_ButtonDownFcn instead of ginput), but I am unable to use it. I'm very new with matlab: be patient
I wrote;
hfig=figure;
imshow('whatever');
ginput(1) % painfully slow
axes_ButtonDownFcn(hfig, 1) % the "1" is because I don't know what I'm supposed to put
function axes_ButtonDownFcn(hObject, eventdata)
crd = get (gca, 'CurrentPoint');
y = crd(1,2)
x = crd(1,1)
end
The result: it shows the position of the mouse... But I wanted it to wait until I press the mouse button
Can you help me
  댓글 수: 1
Dmitry Kaplan
Dmitry Kaplan 2018년 10월 3일
편집: Dmitry Kaplan 2018년 10월 3일
Sure. 1. The reason why ginput() is slow is simple: matlab is becoming a huge bolted-on beast of a code base that doesn't get sufficient usability testing. ginput() used to be very quick and then something happened...
2. The first reason why your code doesn't work is that the buttondown function needs to be defined and then assigned to something. So, do yourself a favor a define a completely seperate function
function print_current_loc_at_button_press(hObject, eventdata)
crd = get (gca, 'CurrentPoint');
fprintf('CurrentLoc is: %f, %f\n', crd(1,1), crd(1,2));
end
3. Assigning this function:
h = imshow('whatever'); set(h,'ButtonDownFcn',@print_current_loc_at_button_press);
Notice that the function is assigned to the object (the image), and not to the axis as previous responders suggested. Assigning the callback to the axis only works for me if the chart contains "regular" graphics, and not an image. Supposedly, fiddling with Hittest properties of gca and h may address this, but the way above is more better :-)

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

카테고리

Help CenterFile Exchange에서 Graphics Performance에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by