How can I publish a script with figures that have been generated outside of this script in MATLAB 7.8 (R2009a)?

1 view (last 30 days)
I have a script that I want to publish along with figures that are already opened in MATLAB. For example, I have a GUI that I want to publish. This GUI creates figures when an user enters a few parameters and hits a PUSH button. I want to publish this GUI with all the figures generated with the user's input. However, using PUBLISH with the GUI function only publishes the GUI, not the figures.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 20 Feb 2013
To publish a MATLAB code file with figures generated outside of this particular file you can force the inclusion of the figures in the published files by making small modifications to figure property for each figure you wish to be included in the publication. These modifications must be done within the MATLAB code file.
For example, the following code modifies every figure's USERDATA to be a random number. By adding the following code to a MATLAB code file, you can force the publication of all the figures existing at the time of publication even if they are not generated in this particular code file:
a = findobj('type', 'figure');
for i = 1:length(a)
set(a(i), 'userdata',rand);
end
You may also try using FINDOBJ on the TAG property if you need to specify one figure instead of publishing all the figures.
If you are doing this for GUIs created using GUIDE, please include the above code in the OpeningFcn.
An alternative way to accomplish this is to save the figures and load them in the file that needs to be published.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Products


Release

R2009a

Community Treasure Hunt

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

Start Hunting!