Underline a character in a string text

조회 수: 80 (최근 30일)
Skander
Skander 2013년 12월 22일
댓글: Dyuman Joshi 2024년 3월 27일
Hi, I try to display a string containing some characters that are underlined or with a hat? Does someone know how to proceed? Thanks
  댓글 수: 2
Jan
Jan 2013년 12월 22일
What does "display" exactly mean? Where? In the command window, a title of an AXES, inside a button or in the name of a figure?
Skander
Skander 2013년 12월 24일
In text(), title(), etc. Now I have the solution to get the underline but not for the bar. Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2013년 12월 23일
If you use text(), title(), xlabel(), etc. you can use latex which is the default interpreter.
% title('S\underline{tring} now x hat:\hat{x}', 'FontSize', 30, 'Interpreter', 'latex')
title('S\underline{tring}', 'FontSize', 30, 'Interpreter', 'latex')
I couldn't get the hat to work, but the underline worked. MATLAB admits they don't support all LATEX instructions - maybe hat is one of those.
  댓글 수: 2
Skander
Skander 2013년 12월 24일
이동: David 2024년 3월 27일
Thank you very much, the underline works indeed. Do you have a solution for the bar (a dash over a character, to replace the hat)? Thanks
Dyuman Joshi
Dyuman Joshi 2024년 3월 27일
You can use \bar or \overline - the length of the dash is different.
text(0.5, 0.5, 'This is a bar over x - $\bar{x}$', 'Interpreter', 'latex')
figure
text(0.5, 0.5, 'This is a bar over x - $\overline{x}$', 'Interpreter', 'latex')

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Desktop에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by