How can I publish a script with figures that have been generated outside of this script in MATLAB 7.8 (R2009a)?
1 次查看(过去 30 天)
显示 更早的评论
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.
采纳的回答
MathWorks Support Team
2013-2-20
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.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Migrate GUIDE Apps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!