Using MATLAB for presentation

When MATLAB is used for presentation to a large audience, it is necessary to use large font and figure windows which are larger than usual. This is an explantion of how to accomplish this when using a UNIX workstation. Rather it is a description of how it done at Rice.

What we are doing at Rice is a modification of the setup used at Notre Dame by Nancy Stanton, and developed there by Johanes Suhardjo and Henry Harbury. Due to the new features that allow the windows in dfield and pplane to be resizable and the default figure positions to be changed using global variables, the setup can be affected without tampering with the code in dfield and pplane.

In MATLAB v. 4 under UNIX, there are three separate classes of fonts, each of which is controlled in a different way.

The font in the Command Window.

This font is controlled as a UNIX/X Windows feature. The Command Window is an example of an xterm, and the font used is controlled in the way that is standard for xterms. To choose a font other than the default, MATLAB should be opened with a command such as
xterm -g 70x30+20+20 -fn <fontdes> -fb <fontdes> -e matlab
where <fontdes> is a font designation such as
Fonts can be previewed and their designations found using the UNIX/X Windows utility xfontsel.

The fonts in uicontrols

These are the fonts used in the Graphical User Interface in MATLAB, e.g., those used in the Setup windows for dfield and pplane. They are XResources, and they can be changed using the command xrdb. Once changed, they remain in affect until they are changed again or until you log out of your computer.

A convenient way to do this is to put the new resource into a file with a name such as .Matlab, with the contents

figure*fontList: -*-helvetica-*-r-*-*-*-240-*-*-*-*-*-*
Then executing the command
xrdb -merge .Matlab
will effect the change. You will notice that the code coming after the colon in .Matlab is a font designation as described above.

The font used within figure windows

These are the fonts used in titles and labels. They are under the user's control from the MATLAB Command Window. The font size or the font name can be set for individual figures, or the default used by MATLAB can be changed with the MATLAB command set as described in the MATLAB documentation.

For example to change to a 20 point font as the default in all figures and axes, the commands

will suffice.

A convenient way to change defaults consistently is to do it in a startup.m file. This file is executed by MATLAB as part of its start up procedure.

Changing figure characteristics

This too can be accomplished from the Command Window using set. Again the defaults can be changed for all subsequent figures, or the user can change the charateristics of individual figues.

Again it is convenient to make these changes in the startup.m file.

The complete setup at Rice

The situation at Rice may be a little more complicated than it is most places. Here the computers used for classroom presentation are on the student network, and they access special software such as dfield and pplane from the same source as the students. In addition we want the commands used in class to be the same as those used by the students, so that they are not confused. To resolve this we use code that branches on the hostname of the computer being used.

To call up MATLAB, we use a shell script which is really a complicated alias with the name matlab. The contents are:

	[ "`hostname`" = "trigger" ] || [ "`hostname`" = "grenadier" ]
	xrdb -merge /home/math211/bin/.Matlab
	xterm -g 65x24+20+20 -fn "-*-courier-*-r-*-*-*-200-*-*-*-*-*-*" -fb "-*-courier-*-r-*-*-*-200-*-*-*-*-*-*"  -e /usr/site/matlab/bin/matlab &

   	eval '/usr/site/matlab/bin/matlab'
The file .Matlab, has the contents:
figure*fontList: -*-helvetica-*-r-*-*-*-240-*-*-*-*-*-*
Finally the figure and axis fonts and the default figure positions are set in the startup.m file, which is called by MATLAB when it is started. The listing for this file is
% MATLAB startup file to define default font sizes and figure
% positions.  We also make the line size twice the usual.

% First we have to find the hostname of the computer being used.  This
% is not so easy, since MATLAB does not recognize the output of UNIX
% commands.  Instead we have to fool it.

!hostname > jhlkjhkjlhkhj
fid = fopen('jhlkjhkjlhkhj');
hn = fgetl(fid);

% If the hostname is not one of those used in the classroom we do
% nothing.  Otherwise we set things up for big fonts and big figures. 

HN = (strcmp(hn,'trigger'))|(strcmp(hn,'grenadier'));

if HN

% First the fontsize.


% The default figure size.  All MATLAB figures will open with this
% size and position, unless otherwise told.  This includes the Display
% Windows in dfield and pplane.

  rrs = get(0,'screensize');
  rrf = get(0,'defaultfigurepos');
  m = min((rrs(3)-200)/rrf(3), (rrs(4)-200)/rrf(4));
  defpos = [200, rrs(4)-m*rrf(4), m*rrf(3), m*rrf(4)];

% We want the line widths to be 2 points instead of the usual 1.


% Finally define and set the global variables that provide the default
% postions for the dfield and pplane windows.


  DFSETPOS = [15,rrs(4)-380,845,380];
  DFKBDPOS = [15,DFSETPOS(2)-240,490,230];
  DFSETTINGSPOS = [40,min(rrs(4)-420,250),820,420];
  DFZOOMBACKPOS = [329,166,717,515];

  PPSETPOS = [15,267,944,566];
  PPKBDPOS = [39,487,485,297];
  PPEQPTPOS = [51,315,551,395];
  PPZOOMBACKPOS = [329,166,717,515];


  PPSETTINGSPOS = [61,135,793,375];
  PPXYPOS = [128,18,936,643];

This page is maintained by John C. Polking,
Last changed on September 26, 1995.