Adding text to plot

7 ビュー (過去 30 日間)
spardha mahajan
spardha mahajan 2016 年 11 月 16 日
コメント済み: KSSV 2016 年 11 月 16 日
I have two data sets obtained using two different method and at same point in C.
A = [0.11;0.222;0.213;1.34]
B = [1.22;13.22;0.32;0.32]
and corresponding to each data I have numbers for example A(1) and B(1)= 9 A(2) & B(2) = 12 and so on stored in another matrix as C =[9 12 ....]
I want to compare the results A and B over the plot and add text using C i.e. 9, 12,....

回答 (1 件)

KSSV
KSSV 2016 年 11 月 16 日
c = 1:5 ;
A = rand(5,1) ;
B = rand(5,1) ;
plot(c,A,'.-r')
hold on
plot(c,B,'.-b')
text(c,A,num2str(A)) ;
hold on
text(c,B,num2str(B)) ;
  2 件のコメント
spardha mahajan
spardha mahajan 2016 年 11 月 16 日
Thanks for reply but.
length(C) is equal to length(A) and length (B).
The first elements in A and B in plot should be labeled with the text of first element in C and so on till end. Suppose there are 20 elements so the twenth elements in A and B in plot should be labeled with the text of twenthe element in C.
KSSV
KSSV 2016 年 11 月 16 日
Write your code with the help of above. It is not a tough task.

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

カテゴリ

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