フィルターのクリア

Adding text on the graph

2 ビュー (過去 30 日間)
Lia Kirtadze
Lia Kirtadze 2022 年 8 月 29 日
回答済み: Image Analyst 2022 年 8 月 29 日
Hello
I am making multiple plots of two matrixes and I am calculatting correlation coefficient i each case between these matrixes
I want to add correlation coefficient on the graph but I do not want to do it manyally in case of each graph
is there any possible way to generally convert this correlation coefficient value into string and then put this string as a text on the graph
can anyone provide me with proper code to do that
Thank you in advance

回答 (2 件)

David Hill
David Hill 2022 年 8 月 29 日
Look at text command and num2str
text(x,y,num2str(correlationCoefficient))

Image Analyst
Image Analyst 2022 年 8 月 29 日
Not sure what you mean by manually but you can put in code to put text somewhere on your graph.
plot(1:10);
grid on;
xl = xlim;
yl = ylim;
r = 0.995;
xCenter = mean(xl);
yCenter = mean(yl);
str = sprintf('The correlation coeff = %f', r);
text(xCenter, yCenter, str, 'HorizontalAlignment', 'center', 'Color', 'r', 'FontSize', 14);

カテゴリ

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