how to execute loop again and again without double executing the program?

1 回表示 (過去 30 日間)
kanu
kanu 2014 年 4 月 10 日
コメント済み: kanu 2014 年 8 月 12 日
On any image if i clicked two times then i got the distance between that two points. Again i want to do same step without executing the program then which loop will work? I mean how it execute again and again.. my single two points execution is...
promptMessage = sprintf('left click on the two points'); titleBarCaption = 'Continue ?'; button = questdlg(promptMessage,titleBarCaption,'Continue','Cancel','Continue'); if strcmpi(button,'cancel') return; end [x,y] = ginput(2) distance = sqrt((x(2)-x(1))^2+(y(2)-y(1))^2) Message = sprintf('the distance is %3f pixel', distance); uiwait(helpdlg(message));

採用された回答

Mischa Kim
Mischa Kim 2014 年 4 月 10 日
Kanu, something like (not optimized)
...
exitFLAG = true;
while exitFLAG
[x,y] = ginput(2)
if ~strcmp(get(gcf,'Selectiontype'),'normal')
exitFLAG = false; % exit for mouse right-click
end
distance = sqrt((x(2)-x(1))^2+(y(2)-y(1))^2)
Message = sprintf('the distance is %3f pixel', distance);
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWavelet Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by