graphics - How do I tell my MATLAB GUI that I want to plot on it using an external .m file? -


i have gui(made using guide) in there axes on can draw. when saved gui, have .fig file , .m file (whose names start_gui.m , start_gui.fig). now, trying plot on these axes using external m file, have passed gui handles. follows:

function cube_rotate(angle1,angle2,handles)    gcf=start_gui.fig; %this name of gui.fig file in guide     set(gcf,'currentaxes',handles.cube_axes)%this allows plot on gui        %plot end  

handles.cube_axes name of handle in gui created using guide. inspite of passing handles, won't allow me plot in gui. throws error saying:

??? undefined variable "start_gui" or class "start_gui.fig".

start_gui.fig name of gui figure generated in guide. how make plot in axes in start_gui.fig?

thanks help!

you've made few errors. first referring file name without single quotes denote string. second trying open existing figure assigning variable named gcf. give variable gcf contains string 'start_gui.fig'.

instead, open figure command:

fh = hgload('start_gui.fig'); % find/assign axes handle (assuming have 1 axes in figure): ah = findobj(fh,'type','axes'); % , plot axes: plot(ah,0:.1:2*pi,sin(0:.1:2*pi)); 

on secondary note, there reason you're not using m-file generated matlab carry out functionality? using auto-generated m-file, you'll able access handles structure rather using findobj.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -