How do I update plots in a separate GUI window made in GUIDE?
1 view (last 30 days)
Show older comments
I have a program that I'm putting together that plots data in a separate GUI window. As the user interacts with GUI 1 there comes a point where they will press a button to generate a plot. The plot is displayed in a separate GUI window. Here's some pseudo code
GUI 1:
function pushButton_Callback(handles, hObject)
do something
gui2functioncall(handles);
GUI 2:
function gui2_OpeningFcn(hObject, eventdata, handles, varargin)
handles.gui1handles = varargin{1};
handles = initializeplotparams(handles);
[x,y] = calcPlotData(handles);
plotData(x,y);
guidata(hObject, handles)
function plotData(x,y)
plot(handles.axes1, x, y);
So there will be a point when the user is manipulating GUI 1 where they will hit the button to plotData again to plot new data. I originally had it so that I would check if GUI 2 was open by using the findobj function and closing the object if it returned something. However, I would like to keep the window up and just update the axes inside the GUI. Is there an elegant way of doing so?
I thought about using the set() function to set the XData and YData, but I'm not sure how to specify the axes in GUI 2.
Any help is appreciated. Thank you!
0 Comments
Answers (1)
Walter Roberson
on 20 Jul 2015
fig1 = gcf();
fig2 = figure(2,'Position, ....);
ax2 = axes('Parent', fig2);
handles.ax2 = ax2;
guidata(fig1, handles);
Now you can
plot(handles.ax2, ....)
or
image(DATA, 'Parent', handles.ax2)
and so on.
0 Comments
See Also
Categories
Find more on Migrate GUIDE Apps in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!