MATLAB: Continues update of figure with new data entered mannually from GUI

continues update of figure with new data entered mannually from guiMATLAB

Hi,
I am beginner to MatLab and have one question as below:
Question :
  1. i have 2 matlab script file , one has GUI and the other has normal function definition for plotting the figure. when my GUI opens, in the edit text box, i enter the value and my function works accordingly i.e figure get plotted.
Problem : everytime when i update the text box, each time new figure gets open and there are nearly 8 figures, how can i update the figures when new text data is provided ?
Please note : i use scatter, gscatter, dbscan etc for each figure to get plotted
Your feedback will help me out to procced with my current activity.
thank you and waiting for your feedback.
Regards,
Satya

Best Answer

Welcome to the wonderous world of GUIs :)
You can label your figures. Normalized units can be changed to pixels, inches, centimeters etc. and you change the backmost numbers accordingly.
Then, when you plot something in your function, state which figure to update by calling the figure label. You can add as many figures into the same GUI as you want, and as long as you give them different "names", you can easily specify when to update what.
MYGUI=figure('toolbar','figure','MenuBar','none','Name','Sample GUI','NumberTitle','off','Color',[0.85 0.85 0.85],'Units', 'points','Position',[10 , 0, 1135 , 530 ]);
%This labels your GUI, and its name is now "MYGUI".
%That way, you define the figure "MyFigure" to belong to the "MYGUI" parent.
MyFigure = axes('Parent', MYGUI,'Units', 'normalized','HandleVisibility','callback','Position',[0.05,0.50,0.42,0.10]);
%And now, make a plot, add a legend, and label the y-axis on the figure you just labelled "MyFigure".
plot(MyFigure,x_data1,y_data1,'r-',x_data2,y_data2,'b-');
lgnd1=legend(MyFigure,'Sample data 1','Sample data 2','Location','SouthWest');
ylabel(MyFigure,'This label goes on "MyFigure"','FontSize',11,'Interpreter','latex');