How can I add labels to the tree produced by the TREEPLOT function in MATLAB 7.10 (R2010a)?

2 views (last 30 days)
I would like to label the tree produced by the TREEPLOT function in MATLAB 7.10 (R2010a), similar to how it is labled in the documentation for the TREEPLOT function:
doc treeplot
It seems to me that the TREEPLOT function does not have the option to add labels:
nodes = [0 1 2 2 4 4 4 1 8 8 10 10];
treeplot(nodes)

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 18 Oct 2013
You can use TREELAYOUT function to add the labels to the tree created with the TREEPLOT function:
[x,y] = treelayout(nodes);
for i=1:length(x)
text(x(i),y(i),num2str(i))
end
For more information on the TREELAYOUT function execute the following in the MATLAB command prompt:
doc treelayout

More Answers (0)

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2010a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!