フィルターのクリア

customizing point names in matlab

5 ビュー (過去 30 日間)
Ananya Malik
Ananya Malik 2017 年 1 月 11 日
編集済み: Stephen23 2017 年 1 月 11 日
Is there a way to rename the point names in matlab plots? I know the following code will label the points from 1 to k.
for i=1:length(k)
text(xk(i),yk(i),num2str(i))
hold on
end
Is there a way to add a label to the points eg. s1,s2.... sk? TIA.

採用された回答

KSSV
KSSV 2017 年 1 月 11 日
x = rand(5,1) ;
y = rand(5,1) ;
s = repmat('s',5,1) ;
n = [1:5]' ;
str = strcat(s,num2str(n)) ;
plot(x,y,'.r') ;
text(x,y,str)
  1 件のコメント
Ananya Malik
Ananya Malik 2017 年 1 月 11 日
Thank you.

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

その他の回答 (1 件)

Stephen23
Stephen23 2017 年 1 月 11 日
編集済み: Stephen23 2017 年 1 月 11 日
Note that you might like to add some space between the points and the text:
X = rand(5,1) ;
Y = rand(5,1) ;
plot(X,Y,'.r') ;
txt = strcat('s',num2str((1:numel(X)).'));
text(X+0.01,Y,txt)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by