How do I change the text output in Live Scripts?

49 views (last 30 days)
In a Live Script, I make some calculations and want to print out the result. I am using fprintf to do this. For example:
s='text output';
fprintf('Text value is %s',s);
The live script then prints out:
Text value is text output
How do I change the font, the font size, or the font style of the output?
I have tried to change font size in preferences, but none of the options change the font size of the live script output. If I zoom, it zooms everything (live script text as well as the output).
Thanks for any help you can offer
Rodney

Answers (2)

Ankit
Ankit on 24 Jan 2022
@Rodney Smith Please try following links to change the font, font size and font style.
for bold:
fprintf('Hello <strong> bold </strong> world.\n')
I use cprintf - display formatted colored text in Command Window - File Exchange - MATLAB Central (mathworks.com) for changing the font, style etc in MATLAB window. But I didn't tested this on Live Script.
  7 Comments
Rodney Smith
Rodney Smith on 6 Jul 2022
I was premature when I said it works in Live Scripts.
The only thing that seems to work in Live Scripts is the style 'Hyper' , which prints out in blue.
'*Hyper' and '*Text' both print bold.
Sorry

Sign in to comment.


Walter Roberson
Walter Roberson on 8 Jul 2022
The internal mechanism of getting LiveScript to display graphical representation, is to call
matlab.internal.language.signalVariableDisplay(VALUE, NAME)
where NAME is either '' or a character vector giving a displayable variable name (to display on the left hand side of '=' in the display)
VALUE is expected to be either a symbolic object or else a table object (if anything else is accepted, I have not seen evidence of that.)
I do not know how tables are formatted for this purpose.
For symbolic objects, the symbolic object has a property mathmlOutput which is normally created by createMathML(X,symSuggestions) where symSuggestions is the descriptor for the "Other actions" contextual menu (like "Copy output", "evaluate with vpa" and so on.) The createMathML call creates the basic MathML for the object by calling mathml() on the object.
If you put a breakpoint in at the right place in @sym/disp.m and you replace X.mathmlOutput with a different character vector of MathML, then you can get LiveScript to display the altered information. For example I was able to bold a term in a symbolic expression.
Unfortunately...
  • repeated calls to matlab.internal.language.signalVariableDisplay() with altered mathmlOutput properties do not seem to have any effect
  • calling matlab.internal.language.signalVariableDisplay() outside of @sym/disp.m does not seem to have any effect
So, there might be a way to get arbitrary mathML output... but it is not obvious to program that.
I seem to recall from previous investigation that .mlx is zip'd XML and that for text headers and GIF images that it is encoded in mathML inside the XML. If that memory is correct then if, hypothetically, you could reliably trigger outputing arbitrary mathML then interesting outputs would become possible. Unfortunate that there is no clear way to do this.

Products


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by