Error using text() function: "Subscript indices must either be real positive integers or logicals."

1 view (last 30 days)
Hi,
I am plotting a tree using treeplot() and I would like to put some text on the nodes with the treelayout() and text() functions. I get the error when trying to plot the text on the current figure.
This is the code:
t=[0,1,1,2,2] ; [x,y]=treelayout(t) ; treeplot(t) ; text(x(1),y(1),'root')
And this is the error I get:
Subscript indices must either be real positive integers or logicals.
I have tried it with additional parameters without success and I get the same error when using the text() function in any other context. For instances:
figure ; hold on ; plot(rand(1,10),rand(1,10),'ro') ; text(0.5,0.5,'center')
I am using MATLAB 8.2.0.701 (R2013b) for Ubuntu, but I have tried it on the Windows version and I got the same error.
Any suggestion?!
  1 Comment
dpb
dpb on 1 May 2014
You've apparently accidentally aliased text w/ a variable it would appear.
To confirm this, try
which text
and see.
clear text
should restore things to normal.

Sign in to comment.

Answers (1)

Jean Montiel
Jean Montiel on 21 Nov 2016
I looked for an answer like this, thanks... I had a text variable, XD

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!