MATLAB: Change font size of command window

18,468

What about displaying all output in a figure instead of the command line? You could place text-objects and define colors and font sizes.

One way is the following: "File > Preferences > Fonts > Custom" and there set your font and size. But it's not accessible setting from the commandline itsel so you would have to set it manually and afterwards disable it.

Edit:

To pop out a figure and print out a certain variable is easy:

foo = 100;
figure
uid = uicontrol('Style', 'text','String', ['FOO = ' num2str(foo)], 'FontSize', 80, 'ForegroundColor', 'b', 'Units','normalized','Position', [0 0 1 1]); 

you could also specify the position and size of the figure window itself, if you want to. To close the figure later, just use:

delete(gcf);

If you want to update the value of it, just use something like

set(uid, 'String', 'New text')
Share:
18,468
CaptainProg
Author by

CaptainProg

Updated on June 04, 2022

Comments

  • CaptainProg
    CaptainProg almost 2 years

    I would like to temporarily change the font size of the text in the command window of MATLAB. I am running an experiment in which I am standing at the other side of the lab, and need to occasionally read a number from the screen. I don't want all the MATLAB output to be jumbo size forever - just this one variable when it occasionally comes up. I expect there must be some code that increases font size? I know I can adjust for example font colour using the following code:

    com.mathworks.services.Prefs.setColorPref('ColorsText',java.awt.Color.red);
    com.mathworks.services.ColorPrefs.notifyColorListeners('ColorsText');
    

    (The above changes the text in the command window to red). There must be similar code to set font size?

    The ideal solution would be a parameter to add to the fprintf command, such that only the one bit of output is larger. However, I would accept a solution in which the entire output of the screen is made larger temporarily...

    Any help appreciated.