我目前有一个.m文件,可创建大量数字。它目前将这些数字输出到一个PowerPoint中,每个数字一张幻灯片,但是我希望它更加用户友好。我想为此使用带有应用程序设计器的应用程序,但无法弄清楚如何使图形显示在GUI中。
我的目标:在GUI的左侧有一个下拉列表,可让您选择图形标题,然后该图形将出现在GUI右侧的大轴中。
该代码当前在保存每个图形后都会将其关闭,但是可以根据需要进行更改。
有人可以帮我吗?这甚至可能吗?
不是一个完整的答案,而是一些有关如何加载已创建的.fig
文件并将轴复制到uipanel
的指针。
首先创建一些图形:
f1 = figure();
subplot(211)
imagesc(rand(100));
subplot(212)
plot(rand(100,1))
saveas(f1, 'figure1.fig')
然后将此图形加载到您的GUI中。一个非常简单的GUI示例:
fig = uifigure;
fig.Position = [100 100 800 600]
pan1 = uipanel(fig, 'Title', 'Figure', 'Position',[0 0 600 600])
pan2 = uipanel(fig, 'Title', 'Select Figure', 'Position',[600 0 200 600])
f_new = openfig('figure1.fig', 'invisible'); % load 'invisible' so it doesn't popup
ax_to_copy = f_new.Children; % works even with subplots!
% and copy the loaded axes to the uipanel:
copyobj(ax_to_copy, pan1)
结果: