Add Bar over Letter x for mean value symbol

203 次查看(过去 30 天)
Hey guys I got the folloving code and would love to set a bar above the letter x to get the mean-symbol. But it's not functioning.
strVDrift = {['$\overline{x}$_1: ' num2str(bar1_vd),'$\overline{x}$_{2}: ' num2str(bar2_vd),'$\overline{x}$_{3}: ' num2str(bar3_vd)],['$\overline{x}$_{4}: ' num2str(bar4_vd),'$\overline{x}$_{5}: ' num2str(bar5_vd),...
'$\overline{x}$_{6}: ' num2str(bar6_vd)],['$\overline{x}$_{7}: ' num2str(bar7_vd),'$\overline{x}$_{8}: ' num2str(bar8_vd),'$\overline{x}$_{9}: ' num2str(bar9_vd),'$\overline{x}$_{10}: ' num2str(bar10_vd)]};
a7 = annotation('textbox',dim7,'String',strVDrift,'FitBoxToText','on',Interpreter='latex');

回答(1 个)

Star Strider
Star Strider 2022-10-25
Use '$\bar{x}$' to get:
.
  2 个评论
Dennis
Dennis 2022-10-25
编辑:Dennis 2022-10-25
it did not work with my code...
and how can i then attach the subscript numbers?
Star Strider
Star Strider 2022-10-25
It would help to have some of the numbers.
bar1_vd = rand;
bar2_vd = rand;
bar3_vd = rand;
bar4_vd = rand;
bar5_vd = rand;
bar6_vd = rand;
bar7_vd = rand;
bar8_vd = rand;
bar9_vd = rand;
bar10_vd = rand;
strVDrift = {['$\bar{x}_1: ' num2str(bar1_vd) '\bar{x}_{2}: ' num2str(bar2_vd),'\bar{x}_{3}: ' num2str(bar3_vd),'\bar{x}_{4}: ' num2str(bar4_vd),'\bar{x}_{5}: ' num2str(bar5_vd),...
'\bar{x}_{6}: ' num2str(bar6_vd),'\bar{x}_{7}: ' num2str(bar7_vd),'\bar{x}_{8}: ' num2str(bar8_vd),'\bar{x}_{9}: ' num2str(bar9_vd),'\bar{x}_{10}: ' num2str(bar10_vd) '$']};
text(0.1, 0.8, strVDrift, 'Interpreter','latex')
strVDrift = {['$\bar{x}_1: ' num2str(bar1_vd) '$' newline '$' '\bar{x}_{2}: ' num2str(bar2_vd) '$' newline '$' '\bar{x}_{3}: ' num2str(bar3_vd) '$' newline '$' '\bar{x}_{4}: ' num2str(bar4_vd) '$' newline '$' '\bar{x}_{5}: ' num2str(bar5_vd),...
'$' newline '$' '\bar{x}_{6}: ' num2str(bar6_vd) '$' newline '$' '\bar{x}_{7}: ' num2str(bar7_vd) '$' newline '$' '\bar{x}_{8}: ' num2str(bar8_vd) '$' newline '$' '\bar{x}_{9}: ' num2str(bar9_vd) '$' newline '$' '\bar{x}_{10}: ' num2str(bar10_vd) '$']};
text(0.1, 0.4, strVDrift, 'Interpreter','latex')
% a7 = annotation('textbox',dim7,'String',strVDrift,'FitBoxToText','on',Interpreter='latex');
I have no idea what you want to do, so I created two versions of the string.
I used text to test it, and used ‘\bar’ just to make sure it works.
.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by