Getting user input until they select the right choice

4 Ansichten (letzte 30 Tage)
Duncan
Duncan am 6 Sep. 2014
Bearbeitet: per isakson am 6 Sep. 2014
I have a code which requires the user to select a point on a plot. If they select a point that is not on the plot then it will keep asking the user to click on another point. Is the a way to do this? or something similar that I could work with?
Thanks

Antworten (1)

per isakson
per isakson am 6 Sep. 2014
Bearbeitet: per isakson am 6 Sep. 2014
Start simple. Hint:
x = inf;
y = inf;
while is_outside(x,y)
disp('select a point')
[x,y] = ginput(1);
end
where is_outside is a function with a couple of if-statements.
Cntrl+C works.

Kategorien

Mehr zu Data Exploration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by