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

3 views (last 30 days)
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 Comments
Patrick Perales
Patrick Perales on 26 Mar 2019
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

Sign in to comment.

Answers (0)

Categories

Find more on Line Plots 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!