Error using text() function: "Subscript indices must either be real positive integers or logicals."
显示 更早的评论
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 个评论
dpb
2014-5-1
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.
回答(1 个)
Jean Montiel
2016-11-21
0 个投票
I looked for an answer like this, thanks... I had a text variable, XD
类别
在 帮助中心 和 File Exchange 中查找有关 Sparse Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!