how can i change the colors of matrix rows ?

hi, i have build a matix. i have turned diary mode on ('diary on'). i wanna change just last row color of matix in output file. how? thank you.

 Accepted Answer

dpb
dpb on 4 Jul 2021
See the Limitations and Tips section of the doc for diary
Limitations
Because the output of diary is plain text, the log file does not exactly mirror what you see on screen:
  • The diary file does not include graphics (figure windows).
  • The diary file does not preserve syntax highlighting and font preferences.
  • The diary file shows hidden components in the Command Window, such as hyperlink information generated with matlab:, in plain text. For example, if you enter this statement in the Command Windowstr = sprintf('%s%s', ...
'<a href="matlab:magic(4)">', ...
'Generate magic square</a>');
disp(str)
MATLAB displays
However, the diary file, when viewed in a text editor, shows
str = sprintf('%s%s', ...
'<a href="matlab:magic(4)">', ...
'Generate magic square</a>');
disp(str)
<a href="matlab:magic(4)">Generate magic square</a>
Tips
  • To view the contents of the diary file with syntax highlighting, use the type function.

9 Comments

So according to your answer in diary mode it is impossible. In which format can i do the mentioned above question? Tnx
That's what the doc says, not me.
I don't have any idea; I use MATLAB to compute with, not for presentation, so I've never looked into any of the report generation stuff.
I dunno if you were to echo a font color change or embed a TeX color code in the output the result with type would reflect that or not -- that would be only way I could see something might possibly happen with the output stream from diary; as the doc says, all it does is translate and echo what is in the command sequence it sees as the text; the command window display code isn't written to interpret output codes for presentation, it just echoes ASCII characters; only if there is a hardware/software interrupt on a given control string like the linefeed, etc., that is in default terminal display io will those limited control characters be recognized.
I do not fully understand what u said. I just want show one row of matrix with different color in command window and exported file.
dpb
dpb on 5 Jul 2021
Edited: dpb on 5 Jul 2021
See the Tip comment above about type -- it has the facility to draw at least some of the embedded formatting information on the screen when it processes a diary file, but the builtin command window output code simply doesn't have that ability.
"I just want show one row of matrix with different color in command window and exported file."
Well, sometimes we just can't have everything we want. The command window isn't set up to do that; it was a product from 40 years ago when such niceties were unheard of and still is the interface to enter user commands and see output interactively, but is not designed nor intended to be a presentation manager. TMW has products for that purpose specifically or you can export to other formats that do have the facility, but not at the command window.
The new intereactive editor may have some additional facilities; I dunno about that; I've also never used it nor even opened it up as it simply isn't what I'm into with MATLAB. Maybe somebody else will add some other ideas.
Text files also are just that--text files; it takes something like html or other formatting code to produce such effects and then a specialized program to read the file and interpret those commands to put "the right stuff" on the screen. That tool just isn't the command window in MATLAB, sorry.
Thank you for full explanation and the time you spent.
No problem...another way to think of it is it's why there is the Interpreter property for text and tick labels, or why need Adobe Reader for pdf files (and why need .pdf and TeX or LaTeX, etc., etc., ...)

Sign in to comment.

More Answers (0)

Categories

Asked:

on 4 Jul 2021

Commented:

on 6 Jul 2021

Community Treasure Hunt

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

Start Hunting!