Wait for a condition to be met...
20 views (last 30 days)
Show older comments
Dear community, apologies for asking a simple and multiple-times-asked question...
[BatchAbf.x,~]=ginput(nIn);
% some lines are executed...
waitfor(numel(BatchAbf.x)=nIn);
% do not execute from here down until above condition is met
I know i can get away with pause and press enter, but this solution is more suited.
Any help greatly appreciated
2 Comments
Accepted Answer
Jan
on 21 Oct 2017
But ginput(n) waits already until the user has pressed the key n times. Then
if nIn = 2. I click twice on a graph, BatchAbf.x will get two index values, and
numel(BatchAbf.x) = nIn
is solved by the posted code already:
[BatchAbf.x, ~] = ginput(nIn);
Then what exactly is the problem?
2 Comments
Jan
on 21 Oct 2017
I do not understand the purpose of the code. Do you mean:
function RejectPeak
...
[BatchAbf.x,~]=ginput(nIn);
% do something with BatchAbf.x
end
What is the reason for setting a ButtonDown function, which calls a nested function, when this function can be called directly?
Or perhaps you want:
function RejectPeak
set(handles.axes2,'ButtonDownFcn', @numInd);
end
function varargout = numInd(varargin)
[BatchAbf.x,~]=ginput(nIn);
% do something with BatchAbf.x
end
More Answers (2)
See Also
Categories
Find more on Startup and Shutdown in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!