Adding text in scatter plot

4 ビュー (過去 30 日間)
Pallab
Pallab 2016 年 11 月 3 日
コメント済み: Pallab 2016 年 11 月 3 日
Hi All,
I am using a similar code as shown below to add text in a scatter plot in Matlab 2015a. However, I got the error message "Error using subsindex. Function 'subsindex' is not defined for values of class 'cell'." Can you please help me out why did I get that error even after I defined a3 = cellstr(a2)?
x = 1:5; y = 1:5; scatter(x,y); a1 = [1:5]'; a2 = num2str(a1); a3 = cellstr(a2); dx = 0.1; dy = 0.1; % displacement so the text does not overlay the data points text(x+dx, y+dy, a3);

採用された回答

Steven Lord
Steven Lord 2016 年 11 月 3 日
I suspect you received that error when you executed the command "text(x+dx, y+dy, a3);". Is that correct? If so, you've probably defined a variable named text earlier in your code. To resolve the problem, rename your variable named text or delete it.
  1 件のコメント
Pallab
Pallab 2016 年 11 月 3 日
You are right. Thank you so much, Stev. I appreciate your such a quick response.

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

その他の回答 (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