Disp(...) - How to do only ONE word in bold/underlined letters

조회 수: 178 (최근 30일)
Marcel Langner
Marcel Langner 2018년 11월 28일
댓글: Walter Roberson 2021년 5월 28일
Hi,
I want to Display a text which shall look for Example like this:
Hello World!
How to do that? I know it is possible to put a whole text in bold, but is it possible also to put just one word of the sentence in bold?
Thanks
  댓글 수: 3
madhan ravi
madhan ravi 2018년 11월 29일
marcel langner's answer moved here for consistency
I want to display it in the command window
Not here :-)
madhan ravi
madhan ravi 2018년 11월 29일
marcel langner's answer moved here for consistency
Still waiting for help :-)

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

채택된 답변

Walter Roberson
Walter Roberson 2018년 11월 29일
  댓글 수: 7
Walter Roberson
Walter Roberson 2018년 11월 29일
Bold cannot be done without magic.
Glancing at the current version of the code I am not sure bold is even supported at the moment.
What can be done without magic is underlining, such as
fprintf('Will you say <a href="">hello</a>\n')
which will output the hello underlined.
Also without magic you can emit red, with slightly more work:
fprintf('Will you say '); fprintf(2, 'hello\n')
The extra work here is that you need to fprintf() to unit 2 only for the text that is to be red.
Marcel Langner
Marcel Langner 2018년 11월 29일
This is just perfect, thanks :-)

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

추가 답변 (1개)

Peng
Peng 2019년 8월 8일
why don't you use <strong> </strong> pair?
disp('Hello, <strong>World</strong>!');
  댓글 수: 3
Herbert Middleton
Herbert Middleton 2021년 5월 28일
Is there a way this could work for a number? (with "num2str")?
Walter Roberson
Walter Roberson 2021년 5월 28일
fprintf('Hello, <strong>World #%d</strong>!', randi(99))
Hello, World #58!

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

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by