adding text on an image in 2018a

3 ビュー (過去 30 日間)
Greg
Greg 2018 年 4 月 12 日
回答済み: Rik 2018 年 4 月 12 日
Hello, Why text() is returning: "Index in position 1 exceeds array bounds (must not exceed 1)" when I do:
hold on;
imshow(img)
text(20, 40, 'Some text');
hold off;
This example from the documentation also doesn't work.
x = 0:pi/20:2*pi;
y = sin(x);
plot(x,y)
text(pi,0,'\leftarrow sin(\pi)')
I can live without this and have an alternative, but this would fit much nicer in my design. Many thanks
  3 件のコメント
Walter Roberson
Walter Roberson 2018 年 4 月 12 日
It is likely that you have a variable named text
Greg
Greg 2018 年 4 月 12 日
編集済み: Greg 2018 年 4 月 12 日
Rik, Walter, Many thanks for this. I cannot accept this as an answer as this is a comment only.

サインインしてコメントする。

採用された回答

Rik
Rik 2018 年 4 月 12 日
Then I'll repeat my suspicion as an answer: If you have strange errors about indexing, it is often the case that you overwrote (or more specifically: shadowed) the internal function by creating a variable with the same name. This is a mistake that occurs especially often with functions with names like text, sum, and union.
Using the which function, you can find out what function is actually called. Other options include using breakpoints and setting the pause on error flag.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeEntering Commands についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by