How do I change the text output in Live Scripts?
48 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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
0 commentaires
Réponses (2)
Ankit
le 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 commentaires
Lorenzo Marchionne
le 6 Juil 2022
Hi @Rodney Smith, I've tried to use cprintf in Live Script but unfortunately it doesn't work to me (the printed text is always in black). However it does work properly if I use it in a standard script or directly in the command window.
I see you found the way to make it work in Live Script too. Would you be so kind to give me some extra info on how you managed to make it work in live scripts? It would be very appreciated. Thanks :)
Walter Roberson
le 8 Juil 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Entering Commands 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!