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

178 vues (au cours des 30 derniers jours)
Marcel Langner
Marcel Langner le 28 Nov 2018
Commenté : Walter Roberson le 28 Mai 2021
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 commentaires
madhan ravi
madhan ravi le 29 Nov 2018
marcel langner's answer moved here for consistency
I want to display it in the command window
Not here :-)
madhan ravi
madhan ravi le 29 Nov 2018
marcel langner's answer moved here for consistency
Still waiting for help :-)

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 29 Nov 2018
  7 commentaires
Walter Roberson
Walter Roberson le 29 Nov 2018
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 le 29 Nov 2018
This is just perfect, thanks :-)

Connectez-vous pour commenter.

Plus de réponses (1)

Peng
Peng le 8 Août 2019
why don't you use <strong> </strong> pair?
disp('Hello, <strong>World</strong>!');
  3 commentaires
Herbert Middleton
Herbert Middleton le 28 Mai 2021
Is there a way this could work for a number? (with "num2str")?
Walter Roberson
Walter Roberson le 28 Mai 2021
fprintf('Hello, <strong>World #%d</strong>!', randi(99))
Hello, World #58!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Argument Definitions dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by