App Designer or GUIDE- Store and Use Multiple Inputs from the edit box

I am trying to create a plot or figure in the plot, from which the user inputs the the x and y coordinates to plot a point using only two edit boxes. How can you program the edit box to allow it to store a number of (x,y) coordinates without clearing the figure plotted? Refrences and help are appreciated.

댓글 수: 2

What have you tried so far? If plotting a point removes your plot, you probably didn't use hold.
Also I would suggest using the handle of the line object that plot returns to move the point around on later calls (unless you want multiple user-selected points).
Yes the "hold on " worked well to keep all the points plotted by the user. Thank you for that. However now the code does not store the vaules into the table provided by the GUI. THe code is written as,
function X_coord_Callback(hObject, eventdata, handles)
handles.X_coord = str2double(get(hObject,'string'));
guidata(hObject, handles);
function Y_coord_Callback(hObject, eventdata, handles)
handles.Y_coord = str2double(get(hObject,'String'));
guidata(hObject, handles);
function Coord_button_Callback(hObject, eventdata, handles)
hold off
x_coord = handles.X_coord;
y_coord = handles.Y_coord;
axis([0, max(x_coord)+1, 0, max(y_coord)+1])
trussoline = line(handles.X_coord, handles.Y_coord, 'Marker','o','LinStyle','-');
set(trussoline,'Color','red')
x = {handles.X_coord};
y = {handles.Y_coord};
data = get(handles.xy_coorddata,'Data'); % xy_coorddata is a function --> function xy_coorddata_Create(hObject, eventdata, handles
%
for i = 1:handles.deg_free % For loop is used to repeat the storing of values, however this is not what happens the values are displayed in the command window
x = {handles.X_coord};
y = {handles.Y_coord};
t.data = get(handles.xy_coorddata,'Data',data) % This function is used to store the variables into the table which is what happens, however,
data = [x;y]; % like the problem with the points the values are erased with each new point plotted
end
end
function deg_free_Callback(hObject,~,handles)
handles.deg_free = str2double(get(hObject,'String'));
guidata(hObject, handles);
end
So the question is why it does the code not store the values, consecutively, into the table? Is it due the line object you referenced or will I need a struct of some sort? Any reference is appreciated. Thank you

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

답변 (0개)

카테고리

도움말 센터File Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

질문:

2019년 3월 23일

댓글:

2019년 3월 26일

Community Treasure Hunt

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

Start Hunting!

Translated by