From: David on
Bump.
Anyone.....
I am trying to do the same thing.

"Matthias " <saurbier(a)student.tu-freiberg.de> wrote in message <hr8ssf$4hq$1(a)fred.mathworks.com>...
> Hallo,
>
> I have a problem using the uitree functionality. It works fine with directories and models, but I want to display the treeview of a struct.
>
> Example:
> STRUCTROOT.CHILD1.SUB1 etc
>
> STRUCTROOT
> |--CHILD1
> |--SUB1
> |--SUB2
> |--CHILD2
> |--SUB1
>
> I think i have to add a new case in the processNode-Fcn but I don't know how to do the node = uitreenode(...) command. Is there perhaps something else that has to be changed?
>
> Thank you!
From: us on
"David " <david.park(a)nasa.gov> wrote in message <i1q940$63v$1(a)fred.mathworks.com>...
> Bump.
> Anyone.....
> I am trying to do the same thing.
>
> "Matthias " <saurbier(a)student.tu-freiberg.de> wrote in message <hr8ssf$4hq$1(a)fred.mathworks.com>...
> > Hallo,
> >
> > I have a problem using the uitree functionality. It works fine with directories and models, but I want to display the treeview of a struct.
> >
> > Example:
> > STRUCTROOT.CHILD1.SUB1 etc
> >
> > STRUCTROOT
> > |--CHILD1
> > |--SUB1
> > |--SUB2
> > |--CHILD2
> > |--SUB1
> >
> > I think i have to add a new case in the processNode-Fcn but I don't know how to do the node = uitreenode(...) command. Is there perhaps something else that has to be changed?
> >
> > Thank you!

1) do NOT top post...
2) show CSSM the ML code that you've got so far...

us
From: David on
"us " <us(a)neurol.unizh.ch> wrote in message <i1qabc$ohk$1(a)fred.mathworks.com>...
> "David " <david.park(a)nasa.gov> wrote in message <i1q940$63v$1(a)fred.mathworks.com>...
> > Bump.
> > Anyone.....
> > I am trying to do the same thing.
> >
> > "Matthias " <saurbier(a)student.tu-freiberg.de> wrote in message <hr8ssf$4hq$1(a)fred.mathworks.com>...
> > > Hallo,
> > >
> > > I have a problem using the uitree functionality. It works fine with directories and models, but I want to display the treeview of a struct.
> > >
> > > Example:
> > > STRUCTROOT.CHILD1.SUB1 etc
> > >
> > > STRUCTROOT
> > > |--CHILD1
> > > |--SUB1
> > > |--SUB2
> > > |--CHILD2
> > > |--SUB1
> > >
> > > I think i have to add a new case in the processNode-Fcn but I don't know how to do the node = uitreenode(...) command. Is there perhaps something else that has to be changed?
> > >
> > > Thank you!
>
> 1) do NOT top post...
> 2) show CSSM the ML code that you've got so far...
>
> us

sorry.

I Don't have much code, what I am looking for is how to traverse a structure with the ui tree. So i need to set the 'value' entry to a sub structure, and then have some means of changing that sub structures value in the original structure

function Transceiver()
%This is the root function.
root = uitreenode('v0', 'settings', 'Settings', [], false);
tree = uitree('v0', 'Root', root, 'ExpandFcn', @myExpfcn, ...
'SelectionChangeFcn', 'disp(''Selection Changed'')');

% nodes(1) = uitreenode('child 1', 'Child 1', '', 1);
% nodes(2) = uitreenode('child 2', 'Child 2', '', 1);
%


function nodes = myExpfcn(tree, value)
%settings_structure loads a structure, that is all
vars.settings = settings_structure();
ch = fieldnames(vars.(value));
for i=1:length(ch)
if (isstruct(vars.(value).(char(ch(i)))))
iconpath = [matlabroot, '/toolbox/matlab/icons/foldericon.gif'];
nodes(i) = uitreenode('v0',['settings' '.' char(ch(i))], char(ch(i)), iconpath,0);
else
iconpath = [matlabroot, '/toolbox/matlab/icons/HDF_filenew.gif'];
nodes(i) = uitreenode('v0',['settings' '.' char(ch(i))], char(ch(i)), iconpath,1);
end
end
tree.add(tree, nodes);
From: per isakson on
"Matthias " <saurbier(a)student.tu-freiberg.de> wrote in message <hr8ssf$4hq$1(a)fred.mathworks.com>...
> Hallo,
>
> I have a problem using the uitree functionality. It works fine with directories and models, but I want to display the treeview of a struct.
>
> Example:
> STRUCTROOT.CHILD1.SUB1 etc
>
> STRUCTROOT
> |--CHILD1
> |--SUB1
> |--SUB2
> |--CHILD2
> |--SUB1
>
> I think i have to add a new case in the processNode-Fcn but I don't know how to do the node = uitreenode(...) command. Is there perhaps something else that has to be changed?
>
> Thank you!

see the contributions, explorestruct and StructBrowser, in the File Exchange
/ per
From: us on
"David "

one of the many solutions
- this requires you to download one of the var-dissectors from the FEX

#1 =
http://www.mathworks.com/matlabcentral/fileexchange/12278-vsize-a-pedestrian-variable-decoder

#2 =
http://www.mathworks.com/matlabcentral/fileexchange/1348-gettok-a-pedestrian-matlab-constructs-decoder

% the M-file
function atest(varargin)
root=uitreenode('v0','settings','Settings', [], false);
tree=uitree('v0','Root',root,'ExpandFcn',@myExpfcn,...
'SelectionChangeFcn','disp(''Selection Changed'')');
shg;
end
function nodes=myExpfcn(tree,value) %#ok
iconpath=[matlabroot,'/toolbox/matlab/icons/HDF_filenew.gif'];
% simulate loading a STRUCT...
v(1).a{1}=sparse(magic(3)+2i*magic(3));
v(2).a{2}={struct('FA',{'a','bb'},'FB',{magic(5),{}})};
v(2).b{2}=@(x) sind(x);
% disscet the STRUCT...
% ch=vsize(v); % <- FEX #1
ch=gettok(v,'-q','-f',-3); % <- FEX #2
ch=ch(:,1);
for i=1:numel(ch)
cc=char(ch(i));
nodes(i)=uitreenode('v0',...
['settings','.',cc],...
cc,...
iconpath,1);
end
tree.add(tree,nodes);
end

us