Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
UITree Usage

Subject: UITree Usage

From: Zach

Date: 18 Feb, 2010 18:49:04

Message: 1 of 4

I've got a few questions using the undocumented uitree in Matlab.

I've tried the following simple code in R2009a:
window = figure('Units', 'normalized', 'Name', 'Test');
tree_root = uitreenode('root', 'Root', [], false);
tree = uitree('v0','Root',tree_root);
set(tree, 'Units', 'normalized', 'Position', [0 0 1.0 1.0]);

This brings up a blank figure with no uitree and no errors.

If I put in the following without normalized units:
window = figure('Name', 'Test');
tree_root = uitreenode('root', 'Root', [], false);
tree = uitree('v0','Root',tree_root);

I get the tree, but then resizing the figure doesn't resize the tree like I'd want it to.


In addition, I'd like to know if there was a way to insert uicontrols like uitree and the like into custom guis made with GUIDE. Any help would be appreciated.

Thanks.

Subject: UITree Usage

From: Yair Altman

Date: 26 Feb, 2010 14:47:04

Message: 2 of 4

"Zach" <noreply@noreply.com> wrote in message <hlk230$t36$1@fred.mathworks.com>...
> I've got a few questions using the undocumented uitree in Matlab.
>
> I've tried the following simple code in R2009a:
> window = figure('Units', 'normalized', 'Name', 'Test');
> tree_root = uitreenode('root', 'Root', [], false);
> tree = uitree('v0','Root',tree_root);
> set(tree, 'Units', 'normalized', 'Position', [0 0 1.0 1.0]);
>
> This brings up a blank figure with no uitree and no errors.
>
> If I put in the following without normalized units:
> window = figure('Name', 'Test');
> tree_root = uitreenode('root', 'Root', [], false);
> tree = uitree('v0','Root',tree_root);
>
> I get the tree, but then resizing the figure doesn't resize the tree like I'd want it to.


The first alternative works on a R2008a system. Try to insert a drawnow and/or pause(0.02) immediately after your tree() command, to ensure the tree creation has completed - maybe it's an EDT-timing issue. For the second alternative, you can always specify normalized units AFTER you have created the figure and tree.


> In addition, I'd like to know if there was a way to insert uicontrols like uitree and the like into custom guis made with GUIDE. Any help would be appreciated.

Sure - I do this all the time. Simply add the relevant commands (uicontrol, javacomponent etc.) into the *_OutputFcn function of your GUIDE-created m-file (if your GUI is called ABC, then add the commands to the ABC_OutputFcn() function within the ABC.m file).

Yair Altman
http://UndocumentedMatlab.com

Subject: UITree Usage

From: Patrick

Date: 23 Jun, 2011 13:23:04

Message: 3 of 4

I am sorry, please explain further how to use uiTree with GUIDE:
The function ABC_OutputFcn now has only these statements:
% Get default command line output from handles structure
if ~isempty(handles)
    varargout{1} = handles.output;
end
return;

If I have written
tree = uitree(...);

what (and where) should I add into the OutputFcn function to call object tree?

Thank you.
Patrick.

"Yair Altman" wrote in message <hm8mt8$5hu$1@fred.mathworks.com>...
> "Zach" <noreply@noreply.com> wrote in message <hlk230$t36$1@fred.mathworks.com>...
> > I've got a few questions using the undocumented uitree in Matlab.
> >
> > I've tried the following simple code in R2009a:
> > window = figure('Units', 'normalized', 'Name', 'Test');
> > tree_root = uitreenode('root', 'Root', [], false);
> > tree = uitree('v0','Root',tree_root);
> > set(tree, 'Units', 'normalized', 'Position', [0 0 1.0 1.0]);
> >
> > This brings up a blank figure with no uitree and no errors.
> >
> > If I put in the following without normalized units:
> > window = figure('Name', 'Test');
> > tree_root = uitreenode('root', 'Root', [], false);
> > tree = uitree('v0','Root',tree_root);
> >
> > I get the tree, but then resizing the figure doesn't resize the tree like I'd want it to.
>
>
> The first alternative works on a R2008a system. Try to insert a drawnow and/or pause(0.02) immediately after your tree() command, to ensure the tree creation has completed - maybe it's an EDT-timing issue. For the second alternative, you can always specify normalized units AFTER you have created the figure and tree.
>
>
> > In addition, I'd like to know if there was a way to insert uicontrols like uitree and the like into custom guis made with GUIDE. Any help would be appreciated.
>
> Sure - I do this all the time. Simply add the relevant commands (uicontrol, javacomponent etc.) into the *_OutputFcn function of your GUIDE-created m-file (if your GUI is called ABC, then add the commands to the ABC_OutputFcn() function within the ABC.m file).
>
> Yair Altman
> http://UndocumentedMatlab.com

Subject: UITree Usage

From: Yair Altman

Date: 23 Jun, 2011 17:54:04

Message: 4 of 4

http://undocumentedmatlab.com/blog/uitree/

Look there and at the related articles that appear at the bottom of this article

Yair Altman
http://UndocumentedMatlab.com

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us