Info

This question is closed. Reopen it to edit or answer.

Modifying Axes properties from different file than the one it was created in

1 view (last 30 days)
I am working with a simple GUI that has some axes and a push button. Now when the push button is pressed it calls another m file and executes a function, and the results are plotted in figure on the axes. Now what I am trying to do is to modify this axes after the results are plotted. I know I can do this from using set(handles.axes2...., but this can only be used inside the figure file. I want to edit the axes's properties with code in the function file, not the figure file. In more specific terms, I want the syntax to access the axes's handle from outside the file it was created in, (i.e. from the function that performs the calculation)
Thanks

Answers (1)

Walter Roberson
Walter Roberson on 25 May 2012
The set() can be done within any function that can find the appropriate handle. This could be by way of passing in the handles structure, or by way of passing in information (such as the figure handle) that allows the handles structure to be retrieved via guidata(), or by way of having the function findobj() the handle using information such as its Tag.
For example if you were using GUIDE, then any of the callbacks that are created with the hObject, event, and handles parameters, could be moved to individual .m files [you would run into difficulties with GUIDE's automatic renaming of functions as needed when the object names change, but MATLAB would be fine to have them in separate .m files]
  1 Comment
Omair
Omair on 25 May 2012
First off, thanks for your answer. The original figure m file was created using GUIDE with the axes and all. and I then wrote the file that responds to the GUI push button, the one that does the calculation, the plotting, and that I want now to use to edit the axes properties. I'm mentioning this because I'm starting to realize there is a difference between the handles I create, and the ones that are created by GUIDE. I'm rather new and this is something I will take the time to investigate later on, but as for now can you please give me what you see as most appropriate syntax to share the handles from the m file generated by GUIDE with the m file that I wrote. I've already tried accessing them with *set(handles.axes2,...)*, but I get "Input argument "handles" is undefined". What should the top of my written function be? Because that could be causing the problem. As of now, it's :"function taperplotF1ST1()".

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!