簡體   English   中英

如何將圖形加載和卸載到 matlab 應用程序的軸?

[英]How can I load and unload figures into a matlab app's axis?

我目前有一個創建大量數字的文件。 它目前將這些數字輸出到一個幻燈片中,每個數字一張幻燈片,但我更喜歡用戶友好的東西。 我想為此使用帶有應用程序設計器的應用程序,但我無法弄清楚如何使圖形出現在 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)

結果:

在此處輸入圖像描述 在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM