How do I embedded another figure within a figure in MatLab? -


i'm developing gui matlab code using uitab , uitabgroup previous post:

how create tabbed gui in matlab?

however code populates each tabs ui within single function. since user interface going more complicated that, i'm hoping create figure each tab using it's own function .m file , import figure main gui function .m file. attempted returning figure original function main gui:

tabbed interface:

function tabbedui = tab_gui1() ... code tabbed ui end 

main gui:

function test_embeddedgui()      hfig = figure('menubar', 'none');     test = tab_gui1(hfig);      uicontrol('style', 'pushbutton', 'string', 'this simple test', 'callback', @testbutton);      function testbutton(src, evt)          disp('button pressed');     end end 

my problem when create 'sub figure' creates new figure window , doesn't embed main gui's figure.

:/

how create figure can embedded within figure?

instead of creating new new figure, instead pass parent object want embed code into. example, (assuming used linked questions' accepted answer's code):

function tab_gui1(parent)     htabgroup = uitabgroup('parent', parent); % parent here main gui figure.     htabs(1) = uitab('parent', htabgroup, 'title', 'data');     htabs(2) = uitab('parent', htabgroup, 'title', 'params');     htabs(3) = uitab('parent', htabgroup, 'title', 'plot');     set(htabgroup, 'selectedtab', htabs(1));  ... rest of code same  end 

then pass parent object sub gui function:

function test_embeddedgui()     hfig = figure('menubar', 'none');     tab_gui1(hfig);  % parent object being passed main figure.      uicontrol('style', 'pushbutton', 'string', 'this simple test', 'callback', @testbutton);     function testbutton(src, evt)         disp('button pressed');     end end 

however particular arrangement elements can/will overlap:

overlapping buttons

notice buttons overlapping. can gather question, appears want have tabular main interface sub interfaces each tab. suggest creating tabbed interface on main gui , creating uipanel each of tabs. populate uipanels using separate functions. here's quick example:

main ui

function test_embeddedgui()     hfig = figure('menubar', 'none');      htabgroup = uitabgroup('parent', hfig);      htabs(1) = uitab('parent', htabgroup, 'title', 'first');     htabs(2) = uitab('parent', htabgroup, 'title', 'second');     htabs(3) = uitab('parent', htabgroup, 'title', 'third');      set(htabgroup, 'selectedtab', htabs(1));      firstpanel = uipanel('title', 'main panel', 'parent', htabs(1));     secondpanel = uipanel('title', 'secondary panel', 'parent', htabs(2));     thirdpanel = uipanel('title', 'final panel', 'parent', htabs(3));      subui1(firstpanel); end 

subui:

function subui1(parent)     firstbutton = uicontrol('style', 'pushbutton', 'string', 'first button' ...         , 'parent', parent, 'callback', @buttonpress);      function buttonpress(src, evt)         disp('main button press');     end  end 

which create interface so:

yay!  works!


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -