Allow user to draw a line using mouse

조회 수: 9 (최근 30일)
John D
John D 2019년 11월 14일
댓글: Adam Danz 2019년 11월 16일
How can I get a user to draw a line using their mouse in an App Designer app using R2019a?
Edit: If App Designer does not support it, will GUIDE?
Thanks in advance.
  댓글 수: 2
Ajay Kumar
Ajay Kumar 2019년 11월 14일
편집: Ajay Kumar 2019년 11월 14일
Do you mean line on the axes in uifigure?
John D
John D 2019년 11월 14일
Yes

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

채택된 답변

Adam Danz
Adam Danz 2019년 11월 14일
편집: Adam Danz 2019년 11월 14일
If you have the image processing toolbox, use drawline(). Something will have to trigger the function such as a button press or context menu selection. The example below responds to a button press which will then allow the user to click-and-drag a single line on an existing UIAxes.
function ButtonPushed(app, event)
hold(app.UIAxes, 'on')
drawline(app.UIAxes)
% ^^^^^^^^^^ your ui axis handle
end
  댓글 수: 16
John D
John D 2019년 11월 16일
편집: John D 2019년 11월 16일
I have tried it again in a new app, and have now got it to work in GUIDE.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
drawline(handles.axes1);
Adam Danz
Adam Danz 2019년 11월 16일
Ok, good! If you start using a more recent release you could implement it in app designer, too (r2019b or later).

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

제품


릴리스

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by