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.
xterm -g 70x30+20+20 -fn <fontdes> -fb <fontdes> -e matlabwhere <
fontdes
> is a font designation such as
"-*-courier-*-r-*-*-*-200-*-*-*-*-*-*"Fonts can be previewed and their designations found using the UNIX/X Windows utility
xfontsel
.
uicontrols
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 .Matlabwill effect the change. You will notice that the code coming after the colon in
.Matlab
is a font designation as described above.
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
set(0,'defaultaxesfontsize',20); set(0,'defaulttextfontsize',20);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.
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.
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:
if [ "`hostname`" = "trigger" ] || [ "`hostname`" = "grenadier" ] then 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 & else eval '/usr/site/matlab/bin/matlab' fiThe 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
% STARTUP.M % % 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); fclose(fid); delete('jhlkjhkjlhkhj') % 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. set(0,'defaultaxesfontsize',20); set(0,'defaulttextfontsize',20); % 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)]; set(0,'defaultfigurepos',defpos); % We want the line widths to be 2 points instead of the usual 1. set(0,'defaultaxeslinewidth',2); set(0,'defaultlinelinewidth',2); % Finally define and set the global variables that provide the default % postions for the dfield and pplane windows. global DFSETPOS DFKBDPOS DFSETTINGSPOS DFZOOMBACKPOS 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]; global PPSETPOS PPKBDPOS PPEQPTPOS PPZOOMBACKPOS PPSETPOS = [15,267,944,566]; PPKBDPOS = [39,487,485,297]; PPEQPTPOS = [51,315,551,395]; PPZOOMBACKPOS = [329,166,717,515]; global PPSETTINGSPOS PPXYPOS PPSETTINGSPOS = [61,135,793,375]; PPXYPOS = [128,18,936,643]; endThis page is maintained by John C. Polking, polking@rice.edu