MATLAB: How to assign a plot to a variable plot How can we assign a plot to a variable such that when we type the variable the plot appears (as opposed to a number or equation)? Best Answer If the plot is on it's own figure, you can get the figure handle first:hFig1 = figure;plot(1:9, 'b-');% more code to do stuff on other figures;% Now switch back to the first figure:figure(hFig1);If you're on the same figure, you can use the axes handle to switch focus to the axes you want:axes(handles.axes1);plot(1:9, 'b-');% Switch focus to second plot on the same figure.axes(handles.axes2);plot(sin(0:0.1:2*pi), 'b-');% Switch back to axes #1axes(handles.axes1);plot(2:25, 'r-'); Related SolutionsMATLAB: Switch from GUI axes to figure() and back if PlotInFigure handles.Fig1_axes = axes('Parent', figure(1)); plot_into = handles.Fig1_axes;else plot_into = TheHandleOfTheAxesInTheGUI;endplot(plot_into, x, y, '-b'), MATLAB: Add lines to plot if isempty( findobj('Tag','Plot')) == 1 Plot = figure set(Plot, 'Position', [306,200, 1610,1085]); set(Plot,'name','Plot','Tag','Plot','numbertitle','off'); else MakeFigureCurrent = findobj('Tag','Plot') figure(MakeFigureCurrent) hold onendSome day I ll be a MatLabGOD...but not in this life Related QuestionHelp please. i have 2 axes plots on the GUI , i want to reset the output plot(clear the previous output from plot) as i press the load image image button.Figure(2) not opening a new window, simply overwrites figure(1)Plotting in same figure windowHow to show axes when I build a GUI Scatter plot
Best Answer