Plot Text - Index exceeds matrix dimensions

1 回表示 (過去 30 日間)
Detox
Detox 2018 年 6 月 28 日
コメント済み: Jan 2018 年 6 月 28 日
I want to use a text that automatically adapts inside a for-loop in a loglog plot.
It basically needs to write the slope next to a triangle which I create but when I use the dimensions of the triangle as an orientation it throws an error saying "Index exceeds matrix dimensions.
Error in convstudy1 (line 197)
text(x1,y1,'test','FontSize', 18);
The code I use looks like this:
strloc = (triang_y(1)-triang_y(2)); % y-coordinate for text
strtmp2 = triang_x(2)+10; % x-coordinate for text
x1 = [70 100]; %Vector for annotation
y1 = [strloc strloc]; %Vector for annotation
str = sprintf('m = %d',A);
text(x1,y1,str,'FontSize', 18);
Why does it not work? Am I missing something?

採用された回答

Jan
Jan 2018 年 6 月 28 日
I guess that you have redefined "text" as a variable. Check this using the debugger. Type this in the command window:
dbstop if error
Then run the code again. When it stops, check the symbol "text":
which text -all
What do you get as result? If it is a local variable, the inputs are interpreted as indices. The solution is not to use "text" as name of a variable.
  2 件のコメント
Detox
Detox 2018 年 6 月 28 日
編集済み: Detox 2018 年 6 月 28 日
Wow, what an easy fix and I did not realize I defined text as a variable *facepalm*. Thanks a ton!
Jan
Jan 2018 年 6 月 28 日
You are welcome. Your description of the problem was good.

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

その他の回答 (0 件)

カテゴリ

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

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by