Print value of correlation to a plot displaying two functions

2 ビュー (過去 30 日間)
Loriann Chevalier
Loriann Chevalier 2022 年 4 月 18 日
コメント済み: Loriann Chevalier 2022 年 4 月 23 日
Hi everyone,
I have a plot displaying observed (y1) and simulated (y2) data vs year (x). I want to plot each one as a time series to visually compare them, but I would also like to print the value of the rank correlation between them :
corr(y1,y2,'Type','Kendall')
Basically I want to print the result of this on the plot, without having to copy-paste the value
figure(); hold on;
plot(Year,y1);
hold on;
plot(Year,y1);
txt = {'Corr = *value of correlation*'};
text(4,0.5,txt)
Any ideas ?
Thanks !

採用された回答

KSSV
KSSV 2022 年 4 月 18 日
編集済み: KSSV 2022 年 4 月 18 日
R = corr(y1,y2,'Type','Kendall') ;
figure(); hold on;
plot(Year,y1);
hold on;
plot(Year,y1);
str = sprintf('%f',R) ;
txt = ['Corr = ',str];
text(4,0.5,txt)

その他の回答 (1 件)

Sam Chak
Sam Chak 2022 年 4 月 18 日
Perhaps like this?
v = corr(y1,y2,'Type','Kendall');
txt = ['Corr = ', num2str(v)];
text(4, 0.5, 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